Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions e2e/list/fixtures/c.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { describe, it } from '@rstest/core';

describe.each([0])('test c describe each %#', () => {});

describe.for([0])('test c describe for %#', () => {});

describe.runIf(true)('test c describe runIf', () => {});

describe.skipIf(false)('test c describe skipIf', () => {});

it.each([0])('test c it each %#', () => {});

it.for([0])('test c it for %#', () => {});

it.runIf(true)('test c it runIf', () => {});

it.skipIf(false)('test c it skipIf', () => {});
78 changes: 78 additions & 0 deletions e2e/list/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ describe('test list command', () => {
"a.test.ts > test a-2",
"b.test.ts > test b > test b-1",
"b.test.ts > test b-2",
"c.test.ts > test c it each 0",
"c.test.ts > test c it for 0",
"c.test.ts > test c it runIf",
"c.test.ts > test c it skipIf",
]
`);
});
Expand Down Expand Up @@ -75,6 +79,7 @@ describe('test list command', () => {
[
"a.test.ts > test a > test a-1",
"a.test.ts > test a-2",
"c.test.ts > test c it each 0",
]
`);
});
Expand All @@ -99,6 +104,79 @@ describe('test list command', () => {
[
"a.test.ts",
"b.test.ts",
"c.test.ts",
]
`);
});

it('should list tests and suites correctly', async () => {
const { cli, expectExecSuccess } = await runRstestCli({
command: 'rstest',
args: ['list', '--includeSuites'],
options: {
nodeOptions: {
cwd: join(__dirname, 'fixtures'),
},
},
});

await expectExecSuccess();

const logs = cli.stdout?.split('\n').filter(Boolean);

expect(logs).toMatchInlineSnapshot(`
[
"a.test.ts > test a",
"a.test.ts > test a > test a-1",
"a.test.ts > test a-2",
"b.test.ts > test b",
"b.test.ts > test b > test b-1",
"b.test.ts > test b-2",
"c.test.ts > test c describe each 0",
"c.test.ts > test c describe for 0",
"c.test.ts > test c describe runIf",
"c.test.ts > test c describe skipIf",
"c.test.ts > test c it each 0",
"c.test.ts > test c it for 0",
"c.test.ts > test c it runIf",
"c.test.ts > test c it skipIf",
]
`);
});

it('should list tests and suites with location correctly', async () => {
const { cli, expectExecSuccess } = await runRstestCli({
command: 'rstest',
args: ['list', '--includeSuites', '--printLocation'],
options: {
nodeOptions: {
cwd: join(__dirname, 'fixtures'),
},
},
});

await expectExecSuccess();

const logs = cli.stdout?.split('\n').filter(Boolean);

// rspack transpiles describe() to (0,rstest.describe)(), so the location is end of the callee
// FIXME rspack trasnpiles describe.for to describe["for"] so the location is different from describe.each
expect(logs).toMatchInlineSnapshot(`
[
"a.test.ts:3:9 > test a",
"a.test.ts:4:5 > test a > test a-1",
"a.test.ts:9:3 > test a-2",
"b.test.ts:3:9 > test b",
"b.test.ts:4:5 > test b > test b-1",
"b.test.ts:9:3 > test b-2",
"c.test.ts:3:1 > test c describe each 0",
"c.test.ts:5:13 > test c describe for 0",
"c.test.ts:7:1 > test c describe runIf",
"c.test.ts:9:1 > test c describe skipIf",
"c.test.ts:11:1 > test c it each 0",
"c.test.ts:13:7 > test c it for 0",
"c.test.ts:15:1 > test c it runIf",
"c.test.ts:17:1 > test c it skipIf",
]
`);
});
Expand Down
Loading
Loading