Browse Source

integrate jest (#139)

add basic test to see if works
pull/1/head
sanke1 6 years ago committed by Alexey Velikiy
parent
commit
b4698c82b7
  1. 21
      server/jest.config.js
  2. 7
      server/package.json
  3. 7
      server/spec/basic.jest.ts
  4. 8
      server/spec/config.jest.ts
  5. 2
      server/spec/setup_tests.ts
  6. 3
      server/tsconfig.jest.json

21
server/jest.config.js

@ -0,0 +1,21 @@
module.exports = {
"verbose": true,
"globals": {
"ts-jest": {
"useBabelrc": true,
"tsConfigFile": "tsconfig.jest.json"
}
},
"transform": {
"\\.ts": "ts-jest"
},
"testRegex": "(\\.|/)([jt]est)\\.[jt]s$",
"moduleFileExtensions": [
"ts",
"js",
"json"
],
"setupFiles": [
"<rootDir>/spec/setup_tests.ts"
]
};

7
server/package.json

@ -6,7 +6,8 @@
"start": "node dist/server.js",
"dev": "NODE_ENV=development node build/dev-server.js",
"build-prod": "npm rebuild zeromq && webpack --config build/webpack.prod.conf.js",
"build": "npm run build-prod && webpack --config build/webpack.614.prod.conf.js"
"build": "npm run build-prod && webpack --config build/webpack.614.prod.conf.js",
"test": "jest --config jest.config.js"
},
"repository": {
"type": "git",
@ -21,6 +22,7 @@
"dependencies": {},
"devDependencies": {
"@types/es6-promisify": "^6.0.0",
"@types/jest": "^23.1.1",
"@types/koa": "^2.0.45",
"@types/koa-bodyparser": "^4.2.0",
"@types/koa-router": "^7.0.28",
@ -28,6 +30,7 @@
"@types/nedb": "^1.8.0",
"axios": "^0.18.0",
"babel-core": "^6.26.3",
"babel-jest": "^23.4.2",
"babel-loader": "^7.1.4",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
@ -35,6 +38,7 @@
"es6-promise": "^4.2.4",
"event-stream": "^3.3.4",
"file-loader": "^1.1.11",
"jest": "^23.1.1",
"koa": "^2.5.1",
"koa-bodyparser": "^4.2.1",
"koa-router": "^7.4.0",
@ -43,6 +47,7 @@
"node-loader": "^0.6.0",
"nodemon": "^1.17.5",
"ts-loader": "^4.4.1",
"ts-jest": "^23.1.1",
"typescript": "^2.8.3",
"webpack": "^4.12.0",
"webpack-cli": "^3.0.8",

7
server/spec/basic.jest.ts

@ -0,0 +1,7 @@
describe("Basic test", function() {
let text = "I am a basic test";
it("should work", function() {
expect(text).toBe("I am a basic test");
})
})

8
server/spec/config.jest.ts

@ -0,0 +1,8 @@
import { HASTIC_PORT } from '../src/config';
describe("When importing from .ts files", function() {
it("should work", function() {
expect(HASTIC_PORT).toBe(8000)
})
})

2
server/spec/setup_tests.ts

@ -0,0 +1,2 @@
console.log = jest.fn();
console.error = jest.fn();

3
server/tsconfig.jest.json

@ -0,0 +1,3 @@
{
"extends": "./tsconfig"
}
Loading…
Cancel
Save