Skip to content

Commit

Permalink
tests: fix (#2092)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Nov 10, 2020
1 parent c87cf69 commit 2ae99c2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
12 changes: 7 additions & 5 deletions test/env/array/array-env.test.js
Expand Up @@ -4,7 +4,7 @@ const path = require('path');
const execa = require('execa');

const { sync: spawnSync } = execa;
const { run } = require('../../utils/test-utils');
const { run, isWebpack5 } = require('../../utils/test-utils');

const devFile = path.join(__dirname, './bin/dev.js');
const prodFile = path.join(__dirname, './bin/prod.js');
Expand All @@ -17,10 +17,12 @@ describe('env array', () => {
expect(stderr).toBeFalsy();
expect(stdout).toBeTruthy();

const devScript = spawnSync('node', [devFile]);
const prodScript = spawnSync('node', [prodFile]);
if (isWebpack5) {
const devScript = spawnSync('node', [devFile]);
const prodScript = spawnSync('node', [prodFile]);

expect(devScript.stdout).toBe('environment is development');
expect(prodScript.stdout).toBe('environment is production');
expect(devScript.stdout).toBe('environment is development');
expect(prodScript.stdout).toBe('environment is production');
}
});
});
4 changes: 2 additions & 2 deletions test/env/array/webpack.config.js
Expand Up @@ -3,7 +3,7 @@ const webpack = require('webpack');
module.exports = [
{
output: {
filename: './prod.js',
filename: 'prod.js',
},
mode: 'production',
devtool: 'eval-cheap-module-source-map',
Expand All @@ -16,7 +16,7 @@ module.exports = [
},
{
output: {
filename: './dev.js',
filename: 'dev.js',
},
mode: 'development',
target: 'node',
Expand Down
10 changes: 6 additions & 4 deletions test/env/object/object-env.test.js
Expand Up @@ -4,7 +4,7 @@ const path = require('path');
const execa = require('execa');
const { sync: spawnSync } = execa;

const { run } = require('../../utils/test-utils');
const { run, isWebpack5 } = require('../../utils/test-utils');

describe('env object', () => {
it('is able to set env for an object', () => {
Expand All @@ -14,8 +14,10 @@ describe('env object', () => {
expect(stderr).toBeFalsy();
expect(stdout).toBeTruthy();

const executable = path.join(__dirname, './bin/main.js');
const bundledScript = spawnSync('node', [executable]);
expect(bundledScript.stdout).toBe('environment is development');
if (isWebpack5) {
const executable = path.join(__dirname, './bin/main.js');
const bundledScript = spawnSync('node', [executable]);
expect(bundledScript.stdout).toBe('environment is development');
}
});
});

0 comments on commit 2ae99c2

Please sign in to comment.