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

Mocha support (server) #10

Closed
simondel opened this issue Feb 16, 2016 · 4 comments
Closed

Mocha support (server) #10

simondel opened this issue Feb 16, 2016 · 4 comments

Comments

@simondel
Copy link
Member

Server sided Mocha tests are not yet supported by stryker. See #11 for browser based Mocha test support.

@simondel
Copy link
Member Author

Existing projects such as grunt-mocha-test can be used as reference.
The Mocha API can also be viewed in the Mocha source

@simondel simondel added this to the v0.3.0 milestone Mar 24, 2016
@simondel simondel removed this from the v0.3.0 milestone Apr 4, 2016
@simondel
Copy link
Member Author

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.

@nicojs
Copy link
Member

nicojs commented May 27, 2016

Wow! Nice find. This is indeed a problem.

The way i see it: we have 2 possibilities

  1. Override the global require function. Then, if a require call is made, we forward it to the original require directly, unless it starts with . or .., in that case we rewire the require to the sand-boxed version of the file.
  2. 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:

  1. As part of the unit test, the user can use something like Mockery or Rewire to override the global require themselves. This might not be a problem, but we'll have to test it anyway.
  2. How do we distinguish between a require statement from the unit test framework and the production code. I might require 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)
  3. 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.

@simondel
Copy link
Member Author

simondel pushed a commit that referenced this issue Apr 21, 2017
* feat(read-karma-config): Use karma configuration

Use karma configuration if the `karmaConfigFile` is present.
* Use karma's `files` to fill files in stryker
* Use karma's `exclude` to fill files in stryker prefixed with a `!`.
* Fill other karma settings (preprocessors, base path etc) in `karmaConfig` stryker option. This is later used in the test runner.
* Set test runner to `karma` if not already set.

* feat(read-karma-config): Use karma configuration

Forgot to push utils file

* feat(read-karma-config): Force typescript version

* fix(deps): Update stryker-api version

* feat(config-writer): Never set test runner name

Never set the test runner name to 'karma' as it could lead to strange behavior.
simondel pushed a commit that referenced this issue Apr 21, 2017
* feat(read-karma-config): Use karma configuration

Use karma configuration if the `karmaConfigFile` is present.
* Use karma's `files` to fill files in stryker
* Use karma's `exclude` to fill files in stryker prefixed with a `!`.
* Fill other karma settings (preprocessors, base path etc) in `karmaConfig` stryker option. This is later used in the test runner.
* Set test runner to `karma` if not already set.

* feat(read-karma-config): Use karma configuration

Forgot to push utils file

* feat(read-karma-config): Force typescript version

* fix(deps): Update stryker-api version

* feat(config-writer): Never set test runner name

Never set the test runner name to 'karma' as it could lead to strange behavior.
nicojs pushed a commit that referenced this issue Apr 22, 2017
* Print location of HTML report file when done (#10)
nicojs pushed a commit that referenced this issue Apr 26, 2017
* Print location of HTML report file when done (#10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants