Skip to content

feat(test): expect.getState() + improved test.each support - #11358

Closed
otgerrogla wants to merge 2 commits into
oven-sh:mainfrom
otgerrogla:bun-test
Closed

otgerrogla wants to merge 2 commits into
oven-sh:mainfrom
otgerrogla:bun-test

Conversation

@otgerrogla

@otgerrogla otgerrogla commented May 26, 2024 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Includes the following additions to the testing:

  1. Support for parametrization of test.each / describe.each labels / test names
   test.each([  ['a', 'b']  ])("Test: %s %s")  //--> "Test: a b"
   test.each([  { nested: { value: 1 } }  ])("Test: $nested.value")  //--> "Test: 1"
  1. Support for tagged template string table syntax for test.each:
   describe.each`
   a    | b    | expected
   ${1} | ${1} | ${2}
   ${1} | ${2} | ${3}
   ${2} | ${1} | ${3}
   `('$a + $b', ({a, b, expected}) => { ... });
  1. Support expect.getState(), although not all fields:
    • Implements Support expect.getState() #6213 (partially)
    • Currently supported fields:
      • getState().currentTestName
      • getState().testPath
      • getState().assertionCalls
      • getState().expectedAssertionsNumber
      • getState().isExpectingAssertions
      • getState().expand
  2. Add support for expand flag to the bun test CLI, no built-in matchers use it yet, but it can be used by custom matchers defined with expect.extend() by looking at this.expand
  3. Basic support for this.diff(a, b) in custom matchers
  • Documentation or TypeScript types (it's okay to leave the rest blank in this case)
  • Code changes

How did you verify your code works?

Includes tests for parametrized test names, template string literal each syntax, and getState().

  • I checked the lifetime of memory allocated to verify it's (1) freed and (2) only freed when it should be
  • I included a test for the new code, or an existing test covers it
  • JSValue used outside outside of the stack is either wrapped in a JSC.Strong or is JSValueProtect'ed
  • I wrote TypeScript/JavaScript tests and they pass locally (bun-debug test test-file-name.test)
  • I added TypeScript types for the new methods, getters, or setters

Comment thread src/bun.js/node/util/format.zig Outdated
@github-actions

Copy link
Copy Markdown
Contributor

❌ @dylan-conway, your commit has failing tests :(

💪 2 failing tests Darwin AARCH64

  • test/cli/test/bun-test.test.ts 2 failing
  • test/js/web/streams/streams.test.js 1 failing

💻 2 failing tests Darwin x64 baseline

  • test/cli/test/bun-test.test.ts 2 failing
  • test/js/web/workers/worker.test.ts 1 failing

💻 4 failing tests Darwin x64

  • test/cli/install/bun-create.test.ts 1 failing
  • test/cli/test/bun-test.test.ts 2 failing
  • test/js/node/tls/node-tls-context.test.ts 1 failing
  • test/js/web/fetch/fetch.tls.test.ts 1 failing

🐧💪 1 failing tests Linux AARCH64

  • test/cli/test/bun-test.test.ts 2 failing

🐧🖥 1 failing tests Linux x64 baseline

  • test/cli/test/bun-test.test.ts 2 failing

🐧🖥 2 failing tests Linux x64

  • test/cli/test/bun-test.test.ts 2 failing
  • test/js/node/child_process/child_process-node.test.js 1 failing

🪟💻 12 failing tests Windows x64 baseline

  • test/cli/install/bunx.test.ts 1 failing
  • test/cli/install/registry/bun-install-registry.test.ts 1 failing
  • test/cli/test/bun-test.test.ts 2 failing
  • test/integration/next-pages/test/dev-server-ssr-100.test.ts 1 failing
  • test/integration/next-pages/test/dev-server.test.ts 1 failing
  • test/integration/next-pages/test/next-build.test.ts 1 failing
  • test/js/bun/test/test-test.test.ts 1 failing
  • test/js/node/child_process/child_process.test.ts 1 failing
  • test/js/node/process/process.test.js 2 failing
  • test/js/node/tls/node-tls-context.test.ts code 1
  • test/js/node/watch/fs.watchFile.test.ts SIGKILL
  • test/js/web/fetch/fetch.tls.test.ts 1 failing

🪟💻 7 failing tests Windows x64

  • test/cli/install/bunx.test.ts 1 failing
  • test/cli/install/registry/bun-install-registry.test.ts 1 failing
  • test/cli/test/bun-test.test.ts 2 failing
  • test/js/bun/test/test-test.test.ts 1 failing
  • test/js/node/process/process.test.js 2 failing
  • test/js/node/tls/node-tls-context.test.ts code 1
  • test/js/node/watch/fs.watchFile.test.ts 3 failing

View logs

@Jarred-Sumner

Copy link
Copy Markdown
Collaborator

Closing due to bitrot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants