Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createTaskCollector behaves differently when using .each in version 1.3.0 #5231

Closed
6 tasks done
gudleik opened this issue Feb 19, 2024 · 2 comments · Fixed by #5640
Closed
6 tasks done

createTaskCollector behaves differently when using .each in version 1.3.0 #5231

gudleik opened this issue Feb 19, 2024 · 2 comments · Fixed by #5640

Comments

@gudleik
Copy link

gudleik commented Feb 19, 2024

Describe the bug

Using createTaskCollector, the argument order is different in version 1.3.0 when using test.each() and test().
From custom.test.ts in the reproduction example (see link below):

// copied from https://vitest.dev/advanced/runner.html#your-task-function
export const test = createTaskCollector(function (
  this: any,
  name,
  fn,
  options
) {
  console.dir(
    {
      name,
      fn,
      options,
    },
    { showHidden: true, depth: null }
  );

  getCurrentSuite().task(name, {
    ...this, // so "todo"/"skip"/... is tracked correctly
    meta: {
      customPropertyToDifferentiateTask: true,
    },
    handler: async (...args: any[]) => {
      return fn.apply(this, args);
    },
    options,
  });
});

test('test', () => {
  expect(true).toBe(true);
});

test.each([true, false] as const)('test.each', (bool) => {
  expect(bool).toBe(bool);
});

The output from console.dir:

{
  name: 'test',
  fn: [Function (anonymous)] { [length]: 0, [name]: '' },
  options: undefined
}
{
  name: 'test.each',
  fn: {},
  options: [Function (anonymous)] { [length]: 0, [name]: '' }
}
{
  name: 'test.each',
  fn: {},
  options: [Function (anonymous)] { [length]: 0, [name]: '' }
}

This works fine in version 1.2.2

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-gxa45z?file=test%2Fcustom.test.ts

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.14.0 - /usr/local/bin/pnpm
  npmPackages:
    @vitest/ui: 1.3.0 => 1.3.0 
    vite: latest => 5.1.3 
    vitest: 1.3.0 => 1.3.0

Used Package Manager

npm

Validations

@sheremet-va
Copy link
Member

sheremet-va commented Feb 19, 2024

The order was changed in #5142, but I guess we can keep the old order for the collector (it's not the public order) for now since it looks like a breaking change 🤔

@JCMais
Copy link

JCMais commented Apr 29, 2024

so, any change was made to keep this on the same order? 🤔

@github-actions github-actions bot locked and limited conversation to collaborators May 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants