Skip to content

Commit

Permalink
chore: correct stack trace
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jul 19, 2023
1 parent b413d92 commit 6d5a4c7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"prepublishOnly": "pnpm build"
},
"peerDependencies": {
"vitest": ">=0.32.3"
"vitest": ">=0.34.0"
},
"dependencies": {
"estree-walker": "^3.0.3",
Expand Down
17 changes: 12 additions & 5 deletions test/browser/specs/runner.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ const { stderr, stdout } = await execa('npx', ['vitest', '--run', `--browser.nam
reject: false,
})

await test('tests are actually running', async () => {
const browserResult = await readFile('./browser.json', 'utf-8')
const browserResultJson = JSON.parse(browserResult)
const browserResult = await readFile('./browser.json', 'utf-8')
const browserResultJson = JSON.parse(browserResult)

const getPassed = results => results.filter(result => result.status === 'passed')
const getFailed = results => results.filter(result => result.status === 'failed')

const passedTests = browserResultJson.testResults.filter(result => result.status === 'passed')
const failedTests = browserResultJson.testResults.filter(result => result.status === 'failed')
const passedTests = getPassed(browserResultJson.testResults)
const failedTests = getFailed(browserResultJson.testResults)

await test('tests are actually running', async () => {
assert.ok(browserResultJson.testResults.length === 8, 'Not all the tests have been run')
assert.ok(passedTests.length === 7, 'Some tests failed')
assert.ok(failedTests.length === 1, 'Some tests have passed but should fail')
Expand Down Expand Up @@ -61,6 +64,10 @@ await test('logs are redirected to stderr', async () => {
assert.match(stderr, /Timer "invalid timeEnd" does not exist/, 'prints errored timeEnd')
})

await test('stack trace points to correct file in every browser', () => {
assert.match(stderr, /test\/failing.test.ts:4:12/, 'prints stack trace')
})

await test('popup apis should log a warning', () => {
assert.ok(stderr.includes('Vitest encountered a \`alert\("test"\)\`'), 'prints warning for alert')
assert.ok(stderr.includes('Vitest encountered a \`confirm\("test"\)\`'), 'prints warning for confirm')
Expand Down

0 comments on commit 6d5a4c7

Please sign in to comment.