oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.93k stars 2.75k forks source link

Support parameterized `test.each` with backticks #6364

Open naofunky opened 1 year ago

naofunky commented 1 year ago

What version of Bun is running?

1.0.3

What platform is your computer?

Darwin arm64 arm

What steps can reproduce the bug?

What is actually happening?

The test does not pass when Jest’s Parameterized Test runs, which the test code is written with back quote in the Bun environment.

What kind of environment is it?

Bun:1.0.3

TypeScript:5.2.2

Jest:^29.7.0

@types/jest: ^29.5.5

ts-jest: ^29.1.1

MacOS Ventura:13.4.1

Chrome:117.0.5938.149

npm:9.6.7

yarn:1.22.19

pnpm:8.8.0

How to check this bug

After creating the above environment, a test should be run with the command “bun test file name”.

What is the expected behavior?

The test passes when Jest’s Parameterized Test runs, which the test code is written with back quote in the Bun environment.

What do you see instead?

No response

Additional information

Results when use other package tools

When I run a jest test using npm, yarn, and pnpm, the test passes.

The code I’m trying

it.each`
  a    | b    | expected
  ${1} | ${2} | ${3}
  ${2} | ${2} | ${4}
`('$a and $b add up to $expected', ({ a, b, expected }) => {
  expect(sum(a, b)).toBe(expected);
});

Results in a different notation

If the ParameterizedTest is written with an array instead of using back quote, it passes.

it.each([
   [1, 2, 3],
   [2, 2, 4],
 ])('$a and $b add up to $expected', (a, b, expected) => {
   expect(sum(a, b)).toBe(expected);
});

Reference

Here is a result matrix about each tool and notation.

it would be great if it could help find solution.

スクリーンショット 2023-10-08 17 32 20
Jarred-Sumner commented 1 month ago

Still not implemented as of Bun v1.1.27