Skip to content

Commit

Permalink
test: resolve todos (#2591)
Browse files Browse the repository at this point in the history
  • Loading branch information
cap-Bernardito committed Apr 3, 2021
1 parent 4bb752c commit 2bf24dd
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 48 deletions.
3 changes: 1 addition & 2 deletions test/build/cache/cache.test.js
Expand Up @@ -43,8 +43,7 @@ describe('cache', () => {

if (isWebpack5) {
expect(stderr.match(/No pack exists at/g)).toHaveLength(2);
// TODO buggy
// expect(stderr.match(/Stored pack/g)).toHaveLength(2);
expect(stderr.match(/Stored pack/g)).toHaveLength(2);
expect(stderr).toBeTruthy();
expect(stdout).toBeTruthy();
}
Expand Down
7 changes: 1 addition & 6 deletions test/build/config-format/mjs/mjs.test.js
@@ -1,4 +1,4 @@
const { run, isWindows } = require('../../../utils/test-utils');
const { run } = require('../../../utils/test-utils');

describe('webpack cli', () => {
it('should support mjs config format', async () => {
Expand All @@ -10,11 +10,6 @@ describe('webpack cli', () => {
expect(exitCode).toBe(2);
expect(stdout).toBeFalsy();
} else {
// TODO: fix for windows
if (isWindows) {
expect(true).toBe(true);
return;
}
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toBeTruthy();
Expand Down
7 changes: 1 addition & 6 deletions test/build/config-lookup/custom-name/custom-name.test.js
@@ -1,7 +1,7 @@
'use strict';

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

describe('custom config file', () => {
it('should work with cjs format', async () => {
Expand All @@ -21,11 +21,6 @@ describe('custom config file', () => {
expect(exitCode).toBe(2);
expect(stdout).toBeFalsy();
} else {
// TODO: fix for windows
if (isWindows) {
expect(true).toBe(true);
return;
}
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toBeTruthy();
Expand Down
@@ -1,6 +1,6 @@
const fs = require('fs');
const path = require('path');
const { run, isWebpack5, isWindows } = require('../../../../utils/test-utils');
const { run, isWebpack5 } = require('../../../../utils/test-utils');

describe('Default Config:', () => {
it('Should be able to pick mjs config by default', async () => {
Expand All @@ -10,11 +10,6 @@ describe('Default Config:', () => {
expect(exitCode).toEqual(2);
expect(stdout).toBeFalsy();
} else {
// TODO: fix for windows
if (isWindows) {
expect(true).toBe(true);
return;
}
expect(exitCode).toEqual(0);
expect(stderr).toBeFalsy();
// default entry should be used
Expand Down
10 changes: 1 addition & 9 deletions test/build/config/error-mjs/config-error.test.js
@@ -1,16 +1,8 @@
'use strict';
const { resolve } = require('path');
const { run, isWindows } = require('../../../utils/test-utils');
const { run } = require('../../../utils/test-utils');

describe('config error', () => {
// TODO fix on windows
if (isWindows) {
it('TODO: ix on windows', () => {
expect(true).toBe(true);
});
return;
}

it('should throw error with invalid configuration', async () => {
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', resolve(__dirname, 'webpack.config.mjs')], {
env: { WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG: true },
Expand Down
31 changes: 15 additions & 16 deletions test/build/core-flags/cache-flags.test.js
Expand Up @@ -25,7 +25,7 @@ describe('cache related flags from core', () => {
});

it('should set cache.type', async () => {
const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-type');
const cacheLocation = path.resolve(__dirname, '../../../node_modules/.cache/webpack/cache-core-flag-test-type');

rimraf.sync(cacheLocation);

Expand All @@ -37,7 +37,7 @@ describe('cache related flags from core', () => {
});

it('should set cache.cacheDirectory with --cache-cache-directory', async () => {
const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-cache-directory');
const cacheLocation = path.resolve(__dirname, '../../../node_modules/.cache/webpack/cache-core-flag-test-cache-directory');

rimraf.sync(cacheLocation);

Expand All @@ -57,7 +57,7 @@ describe('cache related flags from core', () => {
});

it('should set cache.cacheLocation with --cache-cache-locations', async () => {
const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-cache-location');
const cacheLocation = path.resolve(__dirname, '../../../node_modules/.cache/webpack/cache-core-flag-test-cache-location');

rimraf.sync(cacheLocation);

Expand All @@ -71,7 +71,7 @@ describe('cache related flags from core', () => {
});

it('should set cache.hashAlgorithm with --cache-hash-algorithm', async () => {
const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-hash-algorithm');
const cacheLocation = path.resolve(__dirname, '../../../node_modules/.cache/webpack/cache-core-flag-test-hash-algorithm');

rimraf.sync(cacheLocation);

Expand All @@ -91,7 +91,7 @@ describe('cache related flags from core', () => {
});

it('should set cache.name with --cache-name', async () => {
const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-name');
const cacheLocation = path.resolve(__dirname, '../../../node_modules/.cache/webpack/cache-core-flag-test-name');

rimraf.sync(cacheLocation);

Expand All @@ -111,7 +111,7 @@ describe('cache related flags from core', () => {
});

it('should set cache.store with --cache-store', async () => {
const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-store');
const cacheLocation = path.resolve(__dirname, '../../../node_modules/.cache/webpack/cache-core-flag-test-store');

rimraf.sync(cacheLocation);

Expand All @@ -131,7 +131,7 @@ describe('cache related flags from core', () => {
});

it('should set cache.version with --cache-version', async () => {
const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-version');
const cacheLocation = path.resolve(__dirname, '../../../node_modules/.cache/webpack/cache-core-flag-test-version');

rimraf.sync(cacheLocation);

Expand All @@ -151,7 +151,7 @@ describe('cache related flags from core', () => {
});

it('should assign cache build dependencies correctly when cache type is filesystem', async () => {
const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-build-dependencies');
const cacheLocation = path.resolve(__dirname, '../../../node_modules/.cache/webpack/cache-core-flag-test-build-dependencies');

rimraf.sync(cacheLocation);

Expand Down Expand Up @@ -189,7 +189,7 @@ describe('cache related flags from core', () => {
it('should assign cache build dependencies correctly when cache type is filesystem in config', async () => {
const cacheLocation = path.resolve(
__dirname,
'../../node_modules/.cache/webpack/cache-core-flag-test-build-dependencies-in-config',
'../../../node_modules/.cache/webpack/cache-core-flag-test-build-dependencies-in-config',
);

rimraf.sync(cacheLocation);
Expand All @@ -216,7 +216,7 @@ describe('cache related flags from core', () => {
});

it('should assign cache build dependencies with multiple configs', async () => {
rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/config-cache'));
rimraf.sync(path.join(__dirname, '../../../node_modules/.cache/webpack/config-cache'));

const { exitCode, stderr, stdout } = await run(__dirname, ['-c', './webpack.cache.config.js', '-c', './webpack.config.js']);

Expand All @@ -229,7 +229,7 @@ describe('cache related flags from core', () => {
});

it('should assign cache build dependencies with default config', async () => {
rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-development'));
rimraf.sync(path.join(__dirname, '../../../node_modules/.cache/webpack/cache-core-flag-test-development'));

const { exitCode, stderr, stdout } = await run(__dirname, ['--cache-type', 'filesystem', '--name', 'cache-core-flag-test']);

Expand All @@ -241,7 +241,7 @@ describe('cache related flags from core', () => {
});

it('should assign cache build dependencies with merged configs', async () => {
const cacheLocation = path.resolve(__dirname, '../../node_modules/.cache/webpack/cache-core-flag-test-merge');
const cacheLocation = path.resolve(__dirname, '../../../node_modules/.cache/webpack/cache-core-flag-test-merge');

rimraf.sync(cacheLocation);

Expand All @@ -263,10 +263,9 @@ describe('cache related flags from core', () => {
// expect(stdout).toContain(`'${path.join(__dirname, './webpack.config.js')}'`);
});

// TODO: fix it later
it.skip('should invalidate cache when config changes', async () => {
rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/default-development'));
rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/default-production'));
it('should invalidate cache when config changes', async () => {
rimraf.sync(path.join(__dirname, '../../../node_modules/.cache/webpack/default-development'));
rimraf.sync(path.join(__dirname, '../../../node_modules/.cache/webpack/default-production'));

// Creating a temporary webpack config
writeFileSync(resolve(__dirname, './webpack.test.config.js'), 'module.exports = {mode: "development"}');
Expand Down
3 changes: 0 additions & 3 deletions test/build/node/node.test.js
Expand Up @@ -2,9 +2,6 @@
const { resolve } = require('path');
const { run } = require('../../utils/test-utils');

// TODO - We pass node args to `nodeOptions` in execa,
// passing via NODE_OPTIONS=<args> in env in execa
// throws different error from what we manually see
describe('node flags', () => {
it('is able to pass the options flags to node js', async () => {
const { exitCode, stderr, stdout } = await run(__dirname, ['--output-path', './bin'], {
Expand Down

0 comments on commit 2bf24dd

Please sign in to comment.