-
-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: pack/build before all e2e tests (#2395)
- Loading branch information
1 parent
41f00e1
commit 417918f
Showing
6 changed files
with
52 additions
and
37 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,22 +1,10 @@ | ||
import { defineConfig } from 'vitest/config' | ||
import { mswExports, customViteEnvironments } from '../support/alias' | ||
|
||
export default defineConfig({ | ||
test: { | ||
dir: './test/e2e', | ||
globals: true, | ||
environment: 'node', | ||
poolOptions: { | ||
threads: { | ||
/** | ||
* @note Run Node.js integration tests in sequence. | ||
* There's a test that involves building the library, | ||
* which results in the "lib" directory being deleted. | ||
* If any tests attempt to run during that window, | ||
* they will fail, unable to resolve the "msw" import alias. | ||
*/ | ||
singleThread: true, | ||
}, | ||
}, | ||
globalSetup: './test/e2e/vitest.global.setup.ts', | ||
}, | ||
}) |
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,7 @@ | ||
declare module 'vitest' { | ||
export interface ProvidedContext { | ||
tarballPath: string | ||
} | ||
} | ||
|
||
export {} |
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,31 @@ | ||
import fs from 'node:fs' | ||
import { fileURLToPath } from 'node:url' | ||
import { spawnSync } from 'node:child_process' | ||
import { invariant } from 'outvariant' | ||
import type { GlobalSetupContext } from 'vitest/node' | ||
import * as packageJson from '../../package.json' | ||
|
||
export default function setup({ provide }: GlobalSetupContext) { | ||
const tarballPath = fileURLToPath( | ||
new URL(`../../msw-${packageJson.version}.tgz`, import.meta.url), | ||
) | ||
|
||
if (fs.existsSync(tarballPath)) { | ||
return | ||
} | ||
|
||
// Pack the library before all E2E tests. | ||
spawnSync('pnpm', ['pack'], { | ||
stdio: 'inherit', | ||
}) | ||
|
||
invariant( | ||
fs.existsSync(tarballPath), | ||
'Failed to set up e2e tests: library tarball not found at "%s"', | ||
tarballPath, | ||
) | ||
|
||
console.log('Library built at "%s"!', tarballPath) | ||
|
||
provide('tarballPath', tarballPath) | ||
} |