-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(runner): support fixture parsing of lowered async syntax (#6531)
- Loading branch information
Showing
4 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { test as base, expect } from "vitest"; | ||
|
||
type Fixture = { | ||
simple: string, | ||
nested: string, | ||
} | ||
|
||
const test = base.extend<Fixture>({ | ||
simple: async ({}, use) => { | ||
await use("simple"); | ||
}, | ||
nested: async ({ simple }, use) => { | ||
await use("nested:" + simple); | ||
}, | ||
}); | ||
|
||
test("test sync", ({ simple, nested }) => { | ||
expect(simple).toBe("simple"); | ||
expect(nested).toBe("nested:simple") | ||
}); | ||
|
||
test("test async", async ({ simple, nested }) => { | ||
expect(simple).toBe("simple"); | ||
expect(nested).toBe("nested:simple") | ||
}); | ||
|
||
test.for([1, 2])("test.for sync %i", (i, { expect, simple, nested }) => { | ||
expect(i).toBeTypeOf("number") | ||
expect(simple).toBe("simple"); | ||
expect(nested).toBe("nested:simple") | ||
}) | ||
|
||
test.for([1, 2])("test.for async %i", async (i, { expect, simple, nested }) => { | ||
expect(i).toBeTypeOf("number") | ||
expect(simple).toBe("simple"); | ||
expect(nested).toBe("nested:simple") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from "vitest/config"; | ||
|
||
export default defineConfig({ | ||
esbuild: { | ||
supported: { | ||
"async-await": false, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import path from 'node:path' | ||
import { expect, test } from 'vitest' | ||
import { runVitest } from '../../test-utils' | ||
|
||
test('fixture parsing works for lowered async syntax', async () => { | ||
const { stdout } = await runVitest({ | ||
root: path.resolve('fixtures/fixture-no-async'), | ||
reporters: ['tap-flat'], | ||
}) | ||
expect(stdout.replaceAll(/\s*# time=.*/g, '')).toMatchInlineSnapshot(` | ||
"TAP version 13 | ||
1..6 | ||
ok 1 - basic.test.ts > test sync | ||
ok 2 - basic.test.ts > test async | ||
ok 3 - basic.test.ts > test.for sync 1 | ||
ok 4 - basic.test.ts > test.for sync 2 | ||
ok 5 - basic.test.ts > test.for async 1 | ||
ok 6 - basic.test.ts > test.for async 2 | ||
" | ||
`) | ||
}) |