Comments (4)
Existing projects such as grunt-mocha-test can be used as reference.
The Mocha API can also be viewed in the Mocha source
from stryker-js.
We only copy the source files of a project to a different location to run the tests. This can cause issues when files are linked to each other using require
statements that have relative paths. Since the test files are not copied, they will still require
the original source files, instead of the copy.
from stryker-js.
Wow! Nice find. This is indeed a problem.
The way i see it: we have 2 possibilities
- Override the global
require
function. Then, if arequire
call is made, we forward it to the originalrequire
directly, unless it starts with.
or..
, in that case we rewire therequire
to the sand-boxed version of the file. - We just include the test files in the sandbox.
The second solution is safest but comes with a performance overhead.
The first solution is very error prone. For example:
- As part of the unit test, the user can use something like
Mockery
orRewire
to override the global require themselves. This might not be a problem, but we'll have to test it anyway. - How do we distinguish between a
require
statement from the unit test framework and the production code. I mightrequire
something like'../../src/MySystemUnderTest'
(clearly should be rewired to the sandbox version), but it could also be something like'../mocks/MockHelper'
(clearly not to be rewired) - We also use
require
to make our code work. That one will also be the rewired one. We need to make sure this doesn't break anything.
I would go for the second solution for now, as it is safer. We can later change it if we want to optimize for performance.
from stryker-js.
https://github.com/stryker-mutator/stryker-mocha-runner
from stryker-js.
Related Issues (20)
- Add additional config options to clear-text reporter HOT 1
- Running Stryker with the new vitest-runner in parallel results in shared data (and false results)
- Add e2e test for vitest in-source testing
- Support "browser-mode" in the vitest runner HOT 1
- Document tap runner
- Document vitest runner
- Add e2e test for tap with ts-node
- File discovery of `@stryker-mutator/tap-runner` requires `glob`
- Stryker.Js never find tests for mutation HOT 6
- Add Vitest and Tap to disableBail e2e test
- [Vitest]: Allow to provide command line options HOT 1
- Stryker init with vue should now use "vitest" HOT 1
- Extend tap-runner plugin configuration to allow using "any" testing framework with TAP support HOT 2
- Cannot find module '@stryker-mutator/api/core' or its corresponding type declarations with v7 HOT 1
- Make bail behavior of tap-runner configurable HOT 4
- Vitest runner reports ` TypeError: Cannot read properties of undefined (reading 'close')` HOT 4
- missing vitest option in `stryker init` command HOT 7
- running with vitest not setting the `NODE_ENV` to `test` HOT 2
- Remove `lerna bootstrap` in favor of "workspaces"
- Allowing to ignore mutation for specifc code with some pattern HOT 3
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 stryker-js.