Refactor Test Suite inside GlueStick project #406
Comments
The spawn with --watch was necessary at the time buuuuut... is definitely not the best solution, especially since --watch is being deprecated. Any solution that allows incremental compilation would work here. Mocha 2 has a complicated and undocumented programmatic method for running tests. If Mocha 3 has improved that, and we can use chokidar to watch files and programmatically re-run tests with incremental compilation, that'd be the best of everything. If we just restart mocha each time, we're looking at 12-15 seconds on every file change before tests even run. This is what caused us to add an alternative test runner into the app to get back to 10ms. We do have to be careful not to run tests and the server in the same process, or wacky stuff happens. Been there before. |
It would be nice to be able to take advantage of mocha's many options straight from the CLI. For example, the --grep option for selecting a set of tests to run. |
I agree, but Mocha's forcing our hand a bit on that one by getting rid of |
Maybe then, it would be worth considering Jest instead? |
It may not be so painful to convert to Jest with things like https://github.com/skovhus/jest-codemods When we started GlueStick, there was a lot of talk about Jest looking like it was basically abandonware… The Jest I'm seeing today looks incredibly different than before. My favorite items on the features list
Some of these might overlap with Mocha but those might be a lot cleaner/simpler/faster? |
Relevant discussion: |
If another test runner produces faster and more reliable results, great! Mocha was a great choice at first because of the incredible speed of the thing (10ms from test run to pass/fail). Once a project has 1000+ tests, running in parallel may help a lot. |
I am on the Jest side in here. Moreover, I'd like to discuss different approach if we move to Jest on folder structure. Right now I see we have
Jest will look into all A part from benefits mentioned in here, you can also:
It might take a bit more of work but I can refactor in a way we do not need Same for Coverage #345 which can be run with |
I would argue for having tests live alongside source files regardless of whether we go with Jest or not - I go as far as putting source.js and source.spec.js in the same folder. There's nothing about Mocha that requires a separate test directory. |
@ferrannp @threehams tests were put into their own folder specifically to mimic Rails… however, I would much rather follow whatever the popular convention for Jest is if we move that direction. We should consider what this means for existing projects that have tests in the
👍 stoked about that I'm on board with moving to Jest |
I'm on board with the best option available, provided it gives quick test results (startup time is much less important). I can't stress enough how much <250ms test results help when using TDD in our current project. |
I believe that's not possible, since tests files are not shown in chrome inspector so it's impossible to set breakpoints in it, also |
@zamotany can you elaborate why inspector won't work? It's simply inspecting a node process running elsewhere, so it works identically to vscode, webstorm, etc. It shouldn't have any specific limitation on whatever system executes the test js, even with dynamic requires. Also afaik |
Node debugger and Chrome Dev Tools have different communication protocols. VS Code/WebStorm/Atom use Node Debugger Protocol.
I couldn't manage to debug Jest running with |
@sethbattin you might wanna try debugging in the PR I sent #437 and share your thoughts about it too ? :) |
will do |
Finally I managed to break Jest test on To make everything work proper
|
There are a few issues with the current test suite:
spawn
might be unnecessary although it was said to have been added for speed.The text was updated successfully, but these errors were encountered: