Skip to content

Commit 2ee0133

Browse files
committed
Run test for different webpack configs
1 parent ce092e5 commit 2ee0133

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+211
-29
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ yarn.lock
1313

1414
.eslintcache
1515
lib/**.js
16-
test/_out
16+
test/**/_out

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ node_js:
1313
- "13"
1414
- "node"
1515

16+
before_script: npm run test-prepare
1617
script: npm test
1718

1819
branches:

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
},
3131
"scripts": {
3232
"lint": "eslint --cache .",
33-
"test": "npm run build && mocha",
33+
"test": "npm run build && mocha \"./test/*/*.spec.js\"",
34+
"test-prepare": "cd test/webpack2 && npm install && cd ../webpack4 && npm install && cd ../webpack5 && npm install",
3435
"build": "babel src --out-dir lib",
3536
"prepublish": "npm run build"
3637
},
@@ -55,14 +56,12 @@
5556
"@babel/core": "^7.7.5",
5657
"@babel/preset-env": "^7.7.6",
5758
"babel-eslint": "^10.0.0",
58-
"css-loader": "^0.28.5",
59+
"core-js": "^3.10.0",
5960
"eslint": "^6.7.2",
6061
"eslint-config-airbnb-base": "^14.0.0",
6162
"eslint-plugin-import": "^2.7.0",
62-
"extract-text-webpack-plugin": "^2.1.0",
6363
"mocha": "^6.2.2",
6464
"pre-commit": "^1.2.2",
65-
"rimraf": "^3.0.0",
66-
"webpack": "^2.3.3"
65+
"rimraf": "^3.0.0"
6766
}
6867
}

test/integrations/source-map-with-import/a.css

Lines changed: 0 additions & 2 deletions
This file was deleted.

test/integrations.js renamed to test/lib/integrations.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,36 @@ const fs = require('fs');
22
const join = require('path').join;
33
const rimraf = require('rimraf');
44
const assert = require('assert');
5-
const webpack = require('webpack');
6-
const getWebpackConfig = require('./webpack.config.js');
75

86
const root = join(__dirname, 'integrations');
9-
const output = join(__dirname, '_out');
107

11-
describe('Integrations with webpack 2', function() {
8+
function runIntegrations(basePath, version) {
129
this.timeout(5000);
1310

14-
const cases = fs.readdirSync(root);
11+
const output = join(basePath, '_out');
1512

1613
rimraf.sync(output);
1714

15+
const nodeVersions = process.version.split('.');
16+
const nodeMajorVersion = parseInt(nodeVersions[0].substring(1), 10);
17+
const nodeMinorVersion = parseInt(nodeVersions[1], 10);
18+
19+
const isEnvCorrect = !(
20+
(version === '4' && nodeMajorVersion === 8 && nodeMinorVersion === 0) ||
21+
(version === '5' && nodeMajorVersion < 10)
22+
);
23+
24+
if (!isEnvCorrect) {
25+
it('webpack ' + version + ' unsuppported with node ' + process.version, function() {
26+
assert.ok(true);
27+
});
28+
return;
29+
}
30+
31+
const cases = fs.readdirSync(root);
32+
const webpack = require(join(basePath, 'node_modules', 'webpack'));
33+
const getWebpackConfig = require(join(basePath, 'webpack.config.js'));
34+
1835
cases.forEach(function(testCase) {
1936
it('with ' + testCase + ' test', function() {
2037
return new Promise(function(resolve, reject) {
@@ -23,6 +40,7 @@ describe('Integrations with webpack 2', function() {
2340
const configFile = join(testDirectory, 'webpack.config.js');
2441

2542
var options = getWebpackConfig({
43+
basePath: basePath,
2644
outputDirectory: outputDirectory,
2745
testDirectory: testDirectory
2846
});
@@ -39,7 +57,7 @@ describe('Integrations with webpack 2', function() {
3957
if (err) return reject(err);
4058
if (stats.hasErrors()) return reject(new Error(stats.toString()));
4159

42-
const expectedCssExt = 'expected.css';
60+
const expectedCssExt = 'expected-v' + version + '.css';
4361

4462
fs.readdir(testDirectory, function(err, files) {
4563
if (err) return reject(err);
@@ -70,4 +88,6 @@ describe('Integrations with webpack 2', function() {
7088
});
7189
});
7290
});
73-
});
91+
}
92+
93+
module.exports = runIntegrations;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.c .d,.local-a.c .d,.local-c .local-d{color:#fff}

0 commit comments

Comments
 (0)