Comments (9)
Here is a quick and dirty workaround that will watch your client directory (you probably need to adjust the file extensions list) and then add whitespace on a test file in the server directory. It's not perfect but it works very nicely =)
You can invoke it like so $ TEST_WATCH=1 TEST_SERVER=0 node ./watch-client.js & meteor npm run test
// watch-client.js
const { watch, promises } = require('fs');
const path = require('path');
(async () => {
const options = {
recursive: true,
};
const whitespacefile = './server/changeMe.tests.js';
const fileHandle = await promises.open(whitespacefile, 'a');
const listener = (eventType, filename) => {
if (!['.js', '.jsx', '.tests.js', '.tests.jsx'].includes(path.extname(filename))) {
console.log(`file ${filename} was changed but is ignored`);
return;
}
console.log(`${eventType} event on file ${path.basename(filename)}, changing whitespace in ${whitespacefile}`);
fileHandle.appendFile(' ');
};
watch('./client', options, listener);
})();
from meteor-mocha.
@lpgeiger This is expected based on how the watch mode stuff works. There's a note about it in the readme here: https://github.com/meteortesting/meteor-mocha#run-app-tests
There may be some way to detect that client was refreshed and send a message to the server telling it to restart.
from meteor-mocha.
@aldeed just curious, what is it that overrides Meteor's default reload mechanism ?
from meteor-mocha.
@hexsprite (late response) It isn't overridden. The page does reload, but our Node driver code that is loading the page in headless browser does not know when this happens, so it doesn't know to restart the test reporting sequence.
from meteor-mocha.
Couldn't we hook into Meteor's hot reload code to know when the Node driver should restart the test reporting sequence?
from meteor-mocha.
@mitar I'm quite new to the meteor internals going this far - but anyone else interested is very welcome to try and find out and share insights.
As a crutch (at least in german we would refer to it as this) you could just add a new-line on a file imported in the server-side code which would make the server reload. Calling it crutch because it helps you getting your way down the road, but it feels too bad for calling it a work-around.
from meteor-mocha.
Digging a bit into this issue, I found two events used by Meteor internally:
https://github.com/meteor/meteor/blob/444f8228b8a46d1035095d606933893e1873b8c3/tools/runners/run-app.js#L822-L830
Here is a sample of usage:
https://github.com/meteor/meteor/blob/d9db4f52f2ea6d706a25156768ea42e1fbb8f599/packages/dynamic-import/server.js#L201-L212
Maybe we're able to run the tests on the client again based on that ... Let's give it a try 😎
from meteor-mocha.
I have now pushed a version which contains a working prototype of this. Please leave a comment on what you think about it:
- When reloading, the message
client-refresh
is sent twice, and the messagewebapp-reload-client
once. In order to keep it readable, I added a message on every call, and also added a message when a run is skipped. - If the client-side tests are still running, the browser will not reload and not restart, so you'll have to wait for the client-tests to finish. First then a reload will trigger a rerun of the tests. This is because the events are triggered multiple times and we do not yet have an option to forcefully close the current browser and ignore the test-results if a rerun is triggered.
from meteor-mocha.
Created a PR for this - all further details should be shared there: #106
from meteor-mocha.
Related Issues (20)
- browser-shim.js prevents nice console logs HOT 1
- Puppeteer app-test yields "TypeError: Cannot read property 'call' of undefined"
- texts from `describe` and `it` blocks are not printed when using browser `nightmare` HOT 3
- Tests are only re-run if I change a *.tests.* file, not if I change implementation files (e.g. server/...) HOT 3
- UnhandledPromiseRejectionWarning: Error: Protocol error (Runtime.callFunctionOn): Promise was collected HOT 1
- Running tests do not finish after the end inside CI HOT 3
- How to setup a global hook for database prefills (fixtures) HOT 2
- XML report output is missing for client tests
- Need upgrade to dependencies to work with Meteor 2.3 HOT 1
- Bump supported dependency versions of lmieulet:meteor-coverage to 4.0.0 HOT 2
- Error: Timeout of 2000ms exceeded
- CSS missing during client side tests due to brower-policy HOT 1
- No tests running in parallel HOT 1
- Allow running specific server tests or hooks after client tests in full app mode
- Run test for multiple specific filename
- Move tests from CI to GitHub actions HOT 3
- The meteor http package is deprecated HOT 3
- Client unit tests not working on Meteor3 with beta HOT 17
- Dependency on jquery? HOT 6
- Eager loading of tests does not work as described in the Meteor guide HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-mocha.