-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Exit with 1 if a test failed (#58)
- Loading branch information
Showing
10 changed files
with
364 additions
and
264 deletions.
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,19 @@ | ||
import { suite } from 'perf-insight'; | ||
|
||
// Use 2 seconds as the default timeout for tests in the suite. | ||
// The `--timeout` option can override this value. | ||
const defaultTimeout = 100; | ||
|
||
// ts-check | ||
suite('fail', 'Example with tests that fail or throw exceptions.', async (test) => { | ||
test('ok', () => { | ||
let a = ''; | ||
for (let i = 0; i < 1000; ++i) { | ||
a = a + 'a'; | ||
} | ||
}); | ||
|
||
test('fail', () => { | ||
throw new Error('This test failed.'); | ||
}); | ||
}).setTimeout(defaultTimeout); // set the default timeout for this suite. |
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
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
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
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 { describe, expect, test } from 'vitest'; | ||
|
||
import { run } from './runBenchmarkCli.mjs'; | ||
|
||
describe('runBenchmarkCli', () => { | ||
test.each` | ||
file | args | root | ||
${'src/exampleMap.perf.mts'} | ${'--suite map -t 500'} | ${'../../../examples/'} | ||
`('runBenchmarkCli $file $args', async ({ file, args, root }) => { | ||
expect(run).toBeTypeOf('function'); | ||
|
||
args = typeof args === 'string' ? args.split(/\s+/g) : args; | ||
const r = new URL(root, import.meta.url).href; | ||
const fileUrl = new URL(file, r).href; | ||
|
||
await expect(run([fileUrl, '--root', r, ...args])).resolves.toEqual({ | ||
error: undefined, | ||
hadFailures: true, | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.