-
-
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.
Browse files
Browse the repository at this point in the history
Co-authored-by: Vladimir Sheremet <[email protected]>
- Loading branch information
1 parent
b8140fc
commit 9e34557
Showing
9 changed files
with
82 additions
and
41 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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export async function importId(id: string) { | ||
const name = `/@id/${id}` | ||
export async function importId(id: string, basePath: string) { | ||
const name = `${basePath}@id/${id}` | ||
// @ts-expect-error mocking vitest apis | ||
return __vi_wrap_module__(import(name)) | ||
} |
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,20 @@ | ||
// fix #4686 | ||
|
||
import assert from 'node:assert' | ||
import test from 'node:test' | ||
import runVitest from './run-vitest.mjs' | ||
|
||
const { | ||
stderr, | ||
browserResultJson, | ||
passedTests, | ||
failedTests, | ||
} = await runVitest(['--config', 'vitest.config-basepath.mts', 'basic.test.ts']) | ||
|
||
await test('tests run in presence of config.base', async () => { | ||
assert.ok(browserResultJson.testResults.length === 1, 'Not all the tests have been run') | ||
assert.ok(passedTests.length === 1, 'Some tests failed') | ||
assert.ok(failedTests.length === 0, 'Some tests have passed but should fail') | ||
|
||
assert.doesNotMatch(stderr, /Unhandled Error/, 'doesn\'t have any unhandled errors') | ||
}) |
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,30 @@ | ||
import { readFile } from 'node:fs/promises' | ||
import { execa } from 'execa' | ||
|
||
const browser = process.env.BROWSER || (process.env.PROVIDER === 'playwright' ? 'chromium' : 'chrome') | ||
|
||
export default async function runVitest(moreArgs = []) { | ||
const argv = ['vitest', '--run', `--browser.name=${browser}`] | ||
|
||
if (browser !== 'safari') | ||
argv.push('--browser.headless') | ||
|
||
const { stderr, stdout } = await execa('npx', argv.concat(moreArgs), { | ||
env: { | ||
...process.env, | ||
CI: 'true', | ||
NO_COLOR: 'true', | ||
}, | ||
reject: false, | ||
}) | ||
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 = getPassed(browserResultJson.testResults) | ||
const failedTests = getFailed(browserResultJson.testResults) | ||
|
||
return { stderr, stdout, browserResultJson, passedTests, failedTests } | ||
} |
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,4 @@ | ||
import { defineConfig, mergeConfig } from 'vitest/config' | ||
import baseConfig from './vitest.config.mjs' | ||
|
||
export default mergeConfig(baseConfig, defineConfig({ base: '/fix-4686' })) |