Skip to content

Commit

Permalink
fix: add NODE_ENV=test, fix autodetect and external msw/node
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias committed Sep 29, 2023
1 parent b244658 commit 62fe8e1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/node/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class NodeRunner {
this.beforeTestsOutput = undefined
this.env = merge(JSON.parse(JSON.stringify(process.env)), {
PW_TEST: this.options,
NODE_ENV: 'test',
})
this.tests =
testFiles ??
Expand Down
1 change: 1 addition & 0 deletions src/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class Runner {
this.watching = false
this.env = merge(JSON.parse(JSON.stringify(process.env)), {
PW_TEST: this.options,
NODE_ENV: 'test',
})
this.beforeTestsOutput = undefined
this.tests =
Expand Down
1 change: 1 addition & 0 deletions src/utils/auto-detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export function detectTestRunner(path, runners) {

if (
node.type === 'VariableDeclaration' &&
node.declarations[0].init &&
node.declarations[0].init.callee &&
node.declarations[0].init.callee.name === 'require' &&
node.declarations[0].init.arguments &&
Expand Down
2 changes: 1 addition & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ await import('${require
plugins: [nodePlugin, watchPlugin, wasmLoader()],
outfile: outPath,
inject: [path.join(__dirname, 'inject-process.js')],
external: ['node:async_hooks', 'node:fs'],
external: ['node:async_hooks', 'node:fs', 'msw/node'],
define: {
global: 'globalThis',
PW_TEST_SOURCEMAP: runner.options.debug ? 'false' : 'true',
Expand Down

0 comments on commit 62fe8e1

Please sign in to comment.