Skip to content

Commit

Permalink
fixed an issue where running in parallel was thrown an error
Browse files Browse the repository at this point in the history
  • Loading branch information
beatfactor committed Jan 18, 2023
1 parent 527027b commit 3d41229
Show file tree
Hide file tree
Showing 5 changed files with 1,456 additions and 73 deletions.
1 change: 1 addition & 0 deletions lib/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module.exports = async function() {
viteConfig.configFile = viteConfigFile;

const viteServer = await vite.start(viteConfig);

const nightwatchPlugin = viteServer.middlewares.stack.find(item => {
return item.route === '/_nightwatch';
});
Expand Down
3 changes: 1 addition & 2 deletions lib/vite.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const vite = require('vite');
const getPort = require('get-port');

module.exports.start = async (opts = {}) => {
const {createServer} = vite;
Expand Down Expand Up @@ -43,7 +42,7 @@ module.exports.start = async (opts = {}) => {
} catch (e) {
console.error(`error when starting dev server:\n${e.stack}`);

return e;
throw e;
}
};

12 changes: 4 additions & 8 deletions nightwatch/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ const stopViteServer = async () => {
};

module.exports = {
async beforeEach(settings) {
if (isWorker) {
await startViteServer.call(this, settings);
}
async beforeChildProcess(settings) {
await startViteServer.call(this, settings);
},

async before(settings) {
Expand All @@ -87,10 +85,8 @@ module.exports = {
return new Promise(resolve => require('rimraf')('nightwatch/.cache', resolve));
},

async afterEach() {
if (isWorker) {
await stopViteServer();
}
async afterChildProcess() {
await stopViteServer();
}
};

Expand Down
Loading

0 comments on commit 3d41229

Please sign in to comment.