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

fix: Reload client side tests 2 #120

Merged
Merged
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
19 changes: 19 additions & 0 deletions package/server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* global Package */
import { mochaInstance } from 'meteor/meteortesting:mocha-core';
import { startBrowser } from 'meteor/meteortesting:browser-tests';
import { onMessage } from 'meteor/inter-process-messaging';

import fs from 'fs';

Expand All @@ -25,6 +26,7 @@ const { grep, invert, reporter, serverReporter, serverOutput, clientOutput } = m
// logging in real time after that if client tests are still running.

let serverTestsDone = false;
let clientTestsRunning = false;
const clientLines = [];
function clientLogBuffer(line) {
if (serverTestsDone) {
Expand Down Expand Up @@ -122,6 +124,11 @@ function serverTests(cb) {
}

function clientTests() {
if (clientTestsRunning) {
console.log('CLIENT TESTS ALREADY RUNNING');
return;
}

if (!runnerOptions.runClient) {
console.log('SKIPPING CLIENT TESTS BECAUSE TEST_CLIENT=0');
exitIfDone('client', 0);
Expand All @@ -136,6 +143,7 @@ function clientTests() {
}

printHeader('CLIENT');
clientTestsRunning = true;

startBrowser({
stdout(data) {
Expand All @@ -160,6 +168,7 @@ function clientTests() {
}
},
done(failureCount) {
clientTestsRunning = false;
if (typeof failureCount !== 'number') {
console.log('The browser driver package did not return a failure count for server tests as expected');
exitIfDone('client', 1);
Expand Down Expand Up @@ -188,3 +197,13 @@ function start() {
}

export { start };

onMessage('client-refresh', (options) => {
console.log('CLIENT TESTS RESTARTING (client-refresh)', options === undefined ? '' : options);
clientTests();
});

onMessage('webapp-reload-client', (options) => {
console.log('CLIENT TESTS RESTARTING (webapp-reload-client)', options === undefined ? '' : options);
clientTests();
});