-
Notifications
You must be signed in to change notification settings - Fork 250
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
Implement hot reload for mocha test runner #2413
Comments
Nice to have a way to track this :)
I get where you're coming from. The first priority is that it must work. The second is speed. But on the other hand, hot reload might be forgotten about when it's not on by default. Is it possible to warn about disabling hot reload when these bad practice errors occur? That way you can turn it on by default, without the annoyance for first-time users. Thinking about it, one way you might identify this is basically this linting rule https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-setup-in-describe.md. Though this will not always be an indication for not being able to use hot reload as it will also flag Another way to identify these bad practices is another tool I use. Choma is a little Mocha plugin that randomizes your tests before execution. It will catch most of these bad practices and could potentially be applied to the initial test run. It won't catch these things when used on a single test and since it's random it won't catch it every time either.
If you expect more reload things to be added, I'd go for this one. If you don't expect others I would use option 2. |
I've been thinking about ways to "discover" if you rely on a bad practice to run your tests. I don't want to be adding checks that rely on a specific test runner or framework. I think maybe we can add a
We could also add some clever metrics to see if the CPU/IO isn't strained too much and suggest a I'm curious to know your take in this. I think I would like to start with hot reload off by default, just to see how it functions in practice. We can always change the default later on 🤷♂️ |
What you're describing is basically an auto-configurator. I think it makes sense, as it would make it really straightforward to setup Stryker in the most efficient way possible. Right now that takes some research for non-trivial projects. It would be especially useful if you use it to tell people why settings do not work for them, what the impact is, and what they have to do to fix it. It would basically allow anyone to troubleshoot most things themselves without much effort. Example: I imagine doing this directly after I imagine it'll be quite a bit of work to get this done, but it's also something that can be build up over time. Maybe starting with a single configuration thing like I do think it will take a bunch of work to get it working, but I also think it would make the barrier of entry lower. That being said, this is not something that should get focus before 4.x has been somewhat polished. With this in mind, I really don't mind hot-reload being off by default. And even if this doesn't get built, the default can always be changed as you said. Additional thoughts With an auto-configurator as described above Stryker would become more than just mutation testing. Basically you're doing everything you can to detect issues in the tests themselves (in this case; bad practices). Linting can do something in this area, but in this case, we're executing the tests to find of if they are good. We're basically talking about high-level testing your tests without the recursive trap of testing tests.
|
We've discussed this in the June 24'th community meetup and decided to not make this behavior configurable. Instead, the test runner plugin itself should decide whether or not to reload the environment (true for static mutants). See #2922 for more information. |
Support native es modules (esm) in the mocha runner. * Uses `loadAsync()` to load the esm files. * Uses [`cleanReferencesAfterRun(false)`](https://mochajs.org/api/mocha#cleanReferencesAfterRun) in order to reuse mocha instances between runs. This comes with a big performance boost (4x) and closes #2413 * Sets `reloadEnvironment` capabilities to `false`. Meaning that static mutants will always force a reload of the environment. This comes with a performance penalty. If you don't want that, please run with `--ignoreStatic`. * Also adds a e2e test for logging, since the `mocha-old-version` e2e test was previously also responsible for testing the logging. This now got moved to its separate test. Closes #2413 BREAKING CHANGE: The `@stryker-mutator/mocha-runner` now requires `[email protected]` or higher.
Closed with #3393, but won't be released before StrykerJS v6 because of breaking changes. |
As discussed with @Lakitna in #1514
We want to implement this feature in the mocha test runner, which supports hot reload since ~7.2 (see mochajs/mocha#4234).
I want to make it optional, since it might break some test suites that don't cleanup nicely between test runs.
For example:
This test will succeed the first time, but fail the second time. This would mark all mutants as killed.
Suggestions:
"hotReloadEnabled": true
false
is default.`"hotReload": true
false
is default`"reloadMode": "hot"
"reload"
by default. Leaves room for adding other modes in the future (for example "restart", which restarts the test runner process between each run)The text was updated successfully, but these errors were encountered: