Skip to content

Commit

Permalink
Polish jasmine2 integration
Browse files Browse the repository at this point in the history
Summary: This polishes the jasmine2 integration from the open source PR ( #330 and D2662964 ):

* Clean up the code, use const/let and classes (I think this is the last holdout in jest to use old patterns? Finally!). Also reformatted a bunch of code with an up-to-date code-style
* Add a `testRunner` option to switch to jasmine2 and resolve the `<rootDir>` correctly (slightly messy, but I'll redo configs and this is how I want it to work in the end).
* Moved a bunch of files around so they make more sense. Reorganized a bunch of stuff, this should now make it more apparent that the test runners are modular and can be switched out. In the future, we'll be able to do `npm install jest-jasmine2`, for example, to get jasmine support.
* Removed the jasmine2 boot file, all of this can be inlined.
* Changed package.json to run the jest tests both for jasmine1 and jasmine2
* Changed the CLI to add the name of the test runner
* Snuck in a small change to the moduleMocker to add WeakMap to the default unmocked collections (cc yungsters).

The plan is for jest 1.0 to switch to jasmine2 by default.

public

Reviewed By: voideanvalue

Differential Revision: D2667164

fb-gh-sync-id: 025ccf685abb550a6eaf9e68c478bc718cba546c
  • Loading branch information
cpojer authored and facebook-github-bot-9 committed Nov 18, 2015
1 parent 9c60191 commit 07b4a83
Show file tree
Hide file tree
Showing 19 changed files with 467 additions and 562 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
@@ -1,5 +1,9 @@
## Unreleased
## master

## 0.8.0

* Added optional support for jasmine2 through the `testRunner` config option.
* Fixed mocking support for Map, WeakMap and Set.
* `node` was added to the defaults in `moduleFileExtensions`.
* Updated the list of node core modules that are properly being recognized by
the module loader.
Expand Down
8 changes: 8 additions & 0 deletions bin/jest.js
Expand Up @@ -165,6 +165,14 @@ const argv = optimist
),
type: 'boolean',
},
testRunner: {
description: _wrapDesc(
'Allows to specify a custom test runner. Jest ships with jasmine2 ' +
'which can be enabled by setting this option to ' +
'`<rootDir>/node_modules/jest-cli/src/testRunners/jasmine/jasmine2.js`'
),
type: 'string',
},
logHeapUsage: {
description: _wrapDesc(
'Logs the heap usage after every test. Useful to debug memory ' +
Expand Down
4 changes: 2 additions & 2 deletions docs/API.md
Expand Up @@ -416,9 +416,9 @@ A regexp pattern string that is matched against all test paths before executing
This is useful if you need to override the default. If you are testing one file at a time the default will be set to `/.*/`, however if you pass a blob rather than a single file the default will then be the absolute path of each test file. The override may be needed on windows machines where, for example, the test full path would be `C:/myproject/__tests__/mystest.jsx.jest` and the default pattern would be set as `/C:\myproject\__tests__\mystest.jsx.jest/`.

### `config.testRunner` [string]
(default: `./jasmineTestRunner/jasmineTestRunner`)
(default: `./testRunners/jasmine/jasmine1.js`)

Allows overriding the default jasmine test runner with the bundled jasmine 2.2 test runner: `./jasmineTestRunner/jasmine2TestRunner`.
This option allows use of a custom test runner. The default is jasmine1. Jest also ships with jasmine2 to which it will default to in the future. jasmine2 can be enabled by setting this option to `<rootDir>/node_modules/jest-cli/src/testRunners/jasmine/jasmine2.js`.

### `config.unmockedModulePathPatterns` [array<string>]
(default: `[]`)
Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -38,7 +38,9 @@
"scripts": {
"lint": "eslint .",
"prepublish": "npm run lint && node bin/jest.js",
"test": "npm run lint && node bin/jest.js"
"test": "npm run lint && npm run jasmine1 && npm run jasmine2",
"jasmine1": "node bin/jest.js --testRunner='<rootDir>/testRunners/jasmine/jasmine1.js'",
"jasmine2": "node bin/jest.js --testRunner='<rootDir>src/testRunners/jasmine/jasmine2.js'"
},
"jest": {
"rootDir": "src",
Expand Down
87 changes: 0 additions & 87 deletions src/jasmineTestRunner/Jasmine2Reporter.js

This file was deleted.

114 changes: 0 additions & 114 deletions src/jasmineTestRunner/JasmineReporter.js

This file was deleted.

0 comments on commit 07b4a83

Please sign in to comment.