Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Flow and Babel dependencies #49

Merged
merged 5 commits into from
Dec 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"presets": [
[
"babel-preset-env",
"@babel/preset-env",
{
"exclude": [
"transform-async-to-generator",
Expand All @@ -11,18 +11,17 @@
]
],
"plugins": [
"babel-plugin-transform-flow-strip-types",
"babel-plugin-transform-decorators-legacy",
"babel-plugin-transform-class-properties",
"babel-plugin-transform-object-rest-spread",
"@babel/plugin-transform-flow-strip-types",
[
"fast-async",
"@babel/plugin-proposal-decorators",
{
"useRuntimeModule": true
"decoratorsBeforeExport": false
}
],
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
"babel-plugin-lodash",
"babel-plugin-transform-runtime"
"@babel/plugin-transform-runtime"
],
"env": {
"coverage": {
Expand Down
29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"build": "yarn run clean-lib && babel ./src -d lib --source-maps",
"lint": "eslint src test bin --fix",
"flow": "flow",
"test": "yarn run clean-tmp && yarn run build && mocha --timeout 10000 --recursive --require babel-register \"test/**/*.test.js\"",
"test": "yarn run clean-tmp && yarn run build && mocha --timeout 10000 --recursive --require @babel/register \"test/**/*.test.js\"",
"cover": "cross-env BABEL_ENV=coverage nyc --reporter=lcov --reporter=text npm test",
"posttest": "yarn run lint",
"docs:clean": "del-cli _book",
Expand Down Expand Up @@ -51,20 +51,21 @@
"webpack": "^4.0.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-flow": "^7.0.0",
"@babel/register": "^7.0.0",
"anymatch": "3.1.1",
"babel-cli": "^6.5.1",
"babel-core": "^6.26.0",
"babel-eslint": "8.2.6",
"babel-loader": "7.1.5",
"babel-eslint": "^9.0.0",
"babel-loader": "^8.0.0",
"babel-plugin-istanbul": "4.1.6",
"babel-plugin-lodash": "^3.2.10",
"babel-plugin-transform-class-properties": "^6.5.2",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-flow-strip-types": "^6.18.0",
"babel-plugin-transform-object-rest-spread": "^6.19.0",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-env": "^1.6.1",
"babel-register": "^6.5.2",
"bdd-lazy-var": "^2.5.0",
"chai": "^4.1.0",
"coffee-script": "^1.11.1",
Expand All @@ -78,7 +79,7 @@
"eslint-plugin-flowtype-errors": "4.1.0",
"eslint-plugin-import": "^2.9.0",
"fast-async": "^6.1.2",
"flow-bin": "0.68.0",
"flow-bin": "^0.113.0",
"fs-extra": "5.0.0",
"gh-pages": "1.2.0",
"gitbook-cli": "^2.3.2",
Expand All @@ -100,7 +101,7 @@
"write-file-webpack-plugin": "^4.2.0"
},
"dependencies": {
"babel-runtime": "^6.26.0",
"@babel/runtime-corejs2": "^7.0.0",
"chalk": "^2.4.2",
"chokidar": "^2.0.0",
"glob-parent": "5.1.0",
Expand Down
3 changes: 0 additions & 3 deletions src/runner/TestRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export default class TestRunner extends EventEmitter {

compiler.hooks.run.tapAsync('mochapack', (c, cb) => {
this.emit('webpack:start');
// $FlowFixMe
cb();
});

Expand Down Expand Up @@ -165,7 +164,6 @@ export default class TestRunner extends EventEmitter {
if (mochaRunner) {
compilationScheduler = () => {
this.emit('webpack:start');
// $FlowFixMe
cb();
};

Expand All @@ -180,7 +178,6 @@ export default class TestRunner extends EventEmitter {
}
} else {
this.emit('webpack:start');
// $FlowFixMe
cb();
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/webpack/util/createStatsFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function createStatsFormatter(rootPath: string) {
return lines.join(EOL);
};

return function statsFormatter(stats: Stats) {
return function statsFormatter(stats: Stats): { errors: Array<string>, warnings: Array<string> } {
const { compilation } = stats;

return {
Expand Down
161 changes: 80 additions & 81 deletions test/integration/cli/watch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ const spawnMochaWebpack = (...args) => {
};

// eslint-disable-next-line
describe('cli --watch', function () {
// FIXME These tests have proven unreliable in the past and are thus disabled
xdescribe('cli --watch', function () {
// Retry all tests in this suite up to 4 times
this.retries(4);

Expand Down Expand Up @@ -466,86 +467,84 @@ describe('cli --watch', function () {
});
});

// FIXME: unreliable behaviour
// it('should recognize new test entries that match the pattern', function () {
// this.timeout(10000);
// const testFile1 = 'test1.js';
// const testId1 = Date.now() + 1;
// const testFile2 = 'test2.js';
// const testId2 = testId1 + 2;
// createTest(testFile1, testId1, true);
// const mw = spawnMochaWebpack('--watch', this.entryGlob);

// return Promise
// .resolve()
// // wait until the output matches our condition
// .then(() => waitFor(() => assert.include(mw.log, testId1) && assert.include(mw.log, '1 passing'), 5000))
// // output matched our condition
// .then(() => {
// // clear log to receive only changes
// mw.clearLog();
// // create new test
// createTest(testFile2, testId2, true);
// })
// // wait until the output matches our condition
// .then(() => waitFor(() => assert.include(mw.log, testId2) && assert.include(mw.log, '1 passing'), 5000))
// .then(() => {
// assert.notInclude(mw.log, testId1);
// assert.notInclude(mw.log, testFile1);
// })
// // output matched our condition
// .catch((e) => e)
// .then((e) => {
// // finally, kill watch process
// mw.kill();
// // maybe rethrow error
// assert.ifError(e);
// });
// });

// FIXME: unreliable behaviour
// it('should recognize multiple new test entries that match the pattern', function () {
// this.timeout(10000);
// const testFile1 = 'test1.js';
// const testId1 = Date.now() + 1;
// const testFile2 = 'test2.js';
// const testId2 = testId1 + 2;
// const testFile3 = 'test3.js';
// const testId3 = testId2 + 3;
// createTest(testFile1, testId1, true);
// const mw = spawnMochaWebpack('--watch', this.entryGlob);

// return Promise
// .resolve()
// // wait until the output matches our condition
// .then(() => waitFor(() => assert.include(mw.log, '1 passing'), 5000))
// // output matched our condition
// .then(() => {
// assert.include(mw.log, testId1);
// assert.include(mw.log, testFile1);

// // clear log to receive only changes
// mw.clearLog();

// // create new tests
// createTest(testFile2, testId2, true);
// createTest(testFile3, testId3, true);
// })
// // wait until the output matches our condition
// .then(() => waitFor(() => assert.include(mw.log, testId2) && assert.include(mw.log, testId3) && assert.include(mw.log, '2 passing'), 5000))
// .then(() => {
// assert.notInclude(mw.log, testId1);
// assert.notInclude(mw.log, testFile1);
// })
// // output matched our condition
// .catch((e) => e)
// .then((e) => {
// // finally, kill watch process
// mw.kill();
// // maybe rethrow error
// assert.ifError(e);
// });
// });
it('should recognize new test entries that match the pattern', function () {
this.timeout(10000);
const testFile1 = 'test1.js';
const testId1 = Date.now() + 1;
const testFile2 = 'test2.js';
const testId2 = testId1 + 2;
createTest(testFile1, testId1, true);
const mw = spawnMochaWebpack('--watch', this.entryGlob);

return Promise
.resolve()
// wait until the output matches our condition
.then(() => waitFor(() => assert.include(mw.log, testId1) && assert.include(mw.log, '1 passing'), 5000))
// output matched our condition
.then(() => {
// clear log to receive only changes
mw.clearLog();
// create new test
createTest(testFile2, testId2, true);
})
// wait until the output matches our condition
.then(() => waitFor(() => assert.include(mw.log, testId2) && assert.include(mw.log, '1 passing'), 5000))
.then(() => {
assert.notInclude(mw.log, testId1);
assert.notInclude(mw.log, testFile1);
})
// output matched our condition
.catch((e) => e)
.then((e) => {
// finally, kill watch process
mw.kill();
// maybe rethrow error
assert.ifError(e);
});
});

it('should recognize multiple new test entries that match the pattern', function () {
this.timeout(10000);
const testFile1 = 'test1.js';
const testId1 = Date.now() + 1;
const testFile2 = 'test2.js';
const testId2 = testId1 + 2;
const testFile3 = 'test3.js';
const testId3 = testId2 + 3;
createTest(testFile1, testId1, true);
const mw = spawnMochaWebpack('--watch', this.entryGlob);

return Promise
.resolve()
// wait until the output matches our condition
.then(() => waitFor(() => assert.include(mw.log, '1 passing'), 5000))
// output matched our condition
.then(() => {
assert.include(mw.log, testId1);
assert.include(mw.log, testFile1);

// clear log to receive only changes
mw.clearLog();

// create new tests
createTest(testFile2, testId2, true);
createTest(testFile3, testId3, true);
})
// wait until the output matches our condition
.then(() => waitFor(() => assert.include(mw.log, testId2) && assert.include(mw.log, testId3) && assert.include(mw.log, '2 passing'), 5000))
.then(() => {
assert.notInclude(mw.log, testId1);
assert.notInclude(mw.log, testFile1);
})
// output matched our condition
.catch((e) => e)
.then((e) => {
// finally, kill watch process
mw.kill();
// maybe rethrow error
assert.ifError(e);
});
});

it('should recognize deleted test entries that match the pattern', function () {
this.timeout(10000);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Error in ./entry.js

Module build failed (from Cdir/node_modules/babel-loader/lib/index.js):
SyntaxError: Unexpected token (2:0)
SyntaxError: Xdir/babel-loader-syntax-error/entry.js: Unexpected token (2:0)

1 | const x = {
> 2 |
Expand Down
7 changes: 3 additions & 4 deletions test/integration/statsFormatter/statsFormatter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const webpackConfig = {
test: /.js$/,
loader: 'babel-loader',
options: {
presets: ['babel-preset-env'],
presets: ['@babel/preset-env'],
},
},
{
Expand Down Expand Up @@ -58,8 +58,8 @@ describe('statFormatter', function () {
const ensureConsistentCompare = _.flow([
stripAnsi,
(message) => message.replace(/\r?\n/g, '\n'),
(message) => message.replace(testDirPath, `Xdir/${testName}`),
(message) => message.replace(process.cwd(), 'Cdir'),
(message) => message.replace(new RegExp(testDirPath, 'g'), `Xdir/${testName}`),
(message) => message.replace(new RegExp(process.cwd(), 'g'), 'Cdir'),
]);

it(`should print correct stats for ${path.basename(testDirPath)}`, function (done) {
Expand Down Expand Up @@ -90,7 +90,6 @@ describe('statFormatter', function () {
assert.isArray(errors, 'statsFormatter should return an Array of errors');
assert.lengthOf(errors, stats.compilation.errors.length, 'Length of errors should match original length');


const warningsContent = ensureConsistentCompare(warnings.join('\n'));
const errorsContent = ensureConsistentCompare(errors.join('\n'));

Expand Down
Loading