From 8b7c8ed72b3c3399bd59d351477144015397db0b Mon Sep 17 00:00:00 2001 From: Nick Excell Date: Wed, 27 May 2020 04:48:25 +0100 Subject: [PATCH] Fix comparison tests under WSL (#1109) * Ensure a separate webpack instance is created if different loader options are used Add execution test for this behaviour * Fix import order (lint error) * Update version to 7.04 and include in changelog * Tweak to Changelog * Add a delay before starting the comparison tests * Update pull request number in changelog * Add comments to link to pull request Co-authored-by: John Reilly --- CHANGELOG.md | 1 + test/comparison-tests/create-and-execute-test.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ebeff967..44198ccf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## v7.0.5 +* [Add a delay before starting the comparison tests to avoid failures under WSL](https://github.com/TypeStrong/ts-loader/pull/1109) - thanks @appzuka * [Apply other loaders when updating files in watch mode](https://github.com/TypeStrong/ts-loader/pull/1115) - thanks @iorate ## v7.0.4 diff --git a/test/comparison-tests/create-and-execute-test.js b/test/comparison-tests/create-and-execute-test.js index 09839de3d..c3b355a22 100644 --- a/test/comparison-tests/create-and-execute-test.js +++ b/test/comparison-tests/create-and-execute-test.js @@ -109,10 +109,16 @@ function createTest(test, testPath, options) { mkdirp.sync(paths.actualOutput); mkdirp.sync(paths.webpackOutput); - // execute webpack - testState.watcher = webpack( - createWebpackConfig(paths, options, nonWatchNonCompositePath !== testPath) - ).watch({ aggregateTimeout: 1500 }, createWebpackWatchHandler(done, paths, testState, options, test)); + + // Need to wait > FS_ACCURACY as defined in watchpack. + // See PR 1109 for details: https://github.com/TypeStrong/ts-loader/pull/1109 + setTimeout(() => { + // execute webpack + testState.watcher = webpack( + createWebpackConfig(paths, options, nonWatchNonCompositePath !== testPath) + ).watch({ aggregateTimeout: 1500 }, createWebpackWatchHandler(done, paths, testState, options, test)); + }, 200); + }; } @@ -275,6 +281,7 @@ function copyPatchOrEndTest(testStagingPath, watcher, testState, done) { if (fs.existsSync(patchPath)) { testState.iteration++; // can get inconsistent results if copying right away + // Probably due to the reaons in PR 1109: https://github.com/TypeStrong/ts-loader/pull/1109 setTimeout(function () { copySync(patchPath, testStagingPath); }, 1000);