Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: testing-library/dom-testing-library
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v8.0.0-alpha.6
Choose a base ref
...
head repository: testing-library/dom-testing-library
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v8.0.0-alpha.7
Choose a head ref
  • 4 commits
  • 2 files changed
  • 1 contributor

Commits on Jun 3, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    56a4c75 View commit details

Commits on Jun 20, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f78d289 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    4c58bc9 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5b15f6f View commit details
Showing with 43 additions and 3 deletions.
  1. +40 −0 src/__tests__/fake-timers.js
  2. +3 −3 types/pretty-dom.d.ts
40 changes: 40 additions & 0 deletions src/__tests__/fake-timers.js
Original file line number Diff line number Diff line change
@@ -79,3 +79,43 @@ test('recursive timers do not cause issues', async () => {

recurse = false
})

// TODO: Should fail i.e. work the same as with "modern fake timers" once https://github.com/facebook/jest/pull/11567 is released.
test('legacy fake timers do not waitFor requestAnimationFrame', async () => {
jest.useFakeTimers('legacy')

let exited = false
requestAnimationFrame(() => {
exited = true
})

await expect(async () => {
await waitFor(() => {
expect(exited).toBe(true)
})
}).rejects.toThrowErrorMatchingInlineSnapshot(`
"expect(received).toBe(expected) // Object.is equality
Expected: true
Received: false
Ignored nodes: comments, <script />, <style />
<html>
<head />
<body />
</html>"
`)
})

test('modern fake timers do waitFor requestAnimationFrame', async () => {
jest.useFakeTimers('modern')

let exited = false
requestAnimationFrame(() => {
exited = true
})

await waitFor(() => {
expect(exited).toBe(true)
})
})
6 changes: 3 additions & 3 deletions types/pretty-dom.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as prettyFormat from 'pretty-format'

export interface PrettyFormatOptions extends prettyFormat.OptionsReceived {
export interface PrettyDOMOptions extends prettyFormat.OptionsReceived {
/**
* Given a `Node` return `false` if you wish to ignore that node in the output.
* By default, ignores `<style />`, `<script />` and comment nodes.
@@ -11,11 +11,11 @@ export interface PrettyFormatOptions extends prettyFormat.OptionsReceived {
export function prettyDOM(
dom?: Element | HTMLDocument,
maxLength?: number,
options?: PrettyFormatOptions,
options?: PrettyDOMOptions,
): string | false
export function logDOM(
dom?: Element | HTMLDocument,
maxLength?: number,
options?: PrettyFormatOptions,
options?: PrettyDOMOptions,
): void
export {prettyFormat}