Skip to content

Commit 6656123

Browse files
committed
chore(Jest): Migrate mocha/chai tests on Jest
1 parent 5c74825 commit 6656123

36 files changed

+567
-890
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
}]
1717
},
1818
"env": {
19-
"mocha": true
19+
"jasmine": true,
20+
"jest": true,
2021
},
2122
"plugins": [
2223
"flowtype"

package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@
4545
"babel-plugin-transform-regenerator": "^6.24.1",
4646
"babel-plugin-transform-runtime": "^6.23.0",
4747
"babel-preset-es2015": "^6.24.1",
48-
"chai": "3.5.0",
49-
"chai-as-promised": "6.0.0",
50-
"chai-spies": "0.7.1",
5148
"cz-conventional-changelog": "^2.0.0",
5249
"eslint": "^3.19.0",
5350
"eslint-config-airbnb-base": "^11.2.0",
@@ -57,12 +54,11 @@
5754
"graphql": "^0.10.1",
5855
"graphql-compose": "^1.19.3",
5956
"graphql-compose-connection": "^2.1.4",
60-
"mocha": "^3.4.2",
57+
"jest": "^20.0.4",
58+
"jest-babel": "^1.0.1",
6159
"mongodb-memory-server": "^1.1.1",
6260
"mongoose": "^4.10.4",
63-
"nyc": "^11.0.2",
6461
"rimraf": "^2.6.1",
65-
"sane": "^1.7.0",
6662
"semantic-release": "^6.3.6"
6763
},
6864
"config": {
@@ -82,15 +78,20 @@
8278
"text"
8379
]
8480
},
81+
"jest": {
82+
"roots": [
83+
"<rootDir>/src"
84+
]
85+
},
8586
"scripts": {
8687
"build": "npm run build-cjs && npm run build-flow && npm run build-es",
8788
"build-cjs": "rimraf lib && babel src --ignore __tests__,__mocks__ -d lib",
8889
"build-es": "rimraf es && BABEL_ENV=es babel src --ignore __tests__,__mocks__ -d es",
8990
"build-flow": "find ./src -name '*.js' -not -path '*/__*' | while read filepath; do cp $filepath `echo $filepath | sed 's/\\/src\\//\\/lib\\//g'`.flow; done",
90-
"coverage": "nyc npm run test",
91+
"coverage": "jest --coverage",
9192
"lint": "eslint src test *.js",
92-
"test": "babel-node ./node_modules/.bin/_mocha --compilers js:babel-core/register --reporter dot --timeout 20000 --require ./resources/mocha-bootload src/**/__tests__/**/*-test.js",
93-
"watch": "babel-node ./resources/watch.js",
93+
"test": "jest",
94+
"watch": "jest --watch",
9495
"link": "yarn build && yarn link graphql && yarn link graphql-compose && yarn link graphql-compose-connection && yarn link mongoose && yarn link",
9596
"unlink": "yarn unlink graphql && yarn unlink graphql-compose && yarn unlink graphql-compose-connection && yarn unlink mongoose && yarn add graphql graphql-compose graphql-compose-connection mongoose",
9697
"semantic-release": "semantic-release pre && npm publish && semantic-release post"

resources/mocha-bootload.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

resources/watch.js

Lines changed: 0 additions & 195 deletions
This file was deleted.

src/__mocks__/mongooseCommon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ mongoServer.getConnectionString().then((mongoUri) => {
1111

1212
mongoose.connection.on('error', (e) => {
1313
if (e.message.code === 'ETIMEDOUT') {
14-
console.log(e);
14+
console.error(e);
1515
mongoose.connect(mongoUri);
1616
} else {
1717
throw e;
1818
}
1919
});
2020

2121
mongoose.connection.once('open', () => {
22-
console.log(`MongoDB successfully connected to ${mongoUri}`);
22+
// console.log(`MongoDB successfully connected to ${mongoUri}`);
2323
});
2424
});
2525

0 commit comments

Comments
 (0)