Skip to content

Commit

Permalink
Don’t use subtests if there is only one test
Browse files Browse the repository at this point in the history
Instead, the single test is run as the main test body.
  • Loading branch information
remcohaszing committed Mar 26, 2024
1 parent 0a1e68e commit e59a02f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/fixtures-directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ export function createTest<T>(
export function testFixturesDirectory<Options>(
options: TestFixturesDirectoryOptions<Options>
): undefined {
const tests = Object.entries(options.tests)
const directory = new URL(options.directory)
if (!directory.pathname.endsWith('/')) {
directory.pathname += '/'
Expand All @@ -259,8 +260,14 @@ export function testFixturesDirectory<Options>(
}

test(dirname, async (t) => {
for (const [name, spec] of Object.entries(options.tests)) {
await t.test(name, createTest(dirUrl, name, options.write, options.prettier, spec))
if (tests.length === 1) {
const [[name, spec]] = tests
const run = createTest(dirUrl, name, options.write, options.prettier, spec)
await run()
} else {
for (const [name, spec] of tests) {
await t.test(name, createTest(dirUrl, name, options.write, options.prettier, spec))
}
}
})
}
Expand Down

0 comments on commit e59a02f

Please sign in to comment.