Skip to content

Commit

Permalink
Added Jest infrastructure for unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
tsv2013 committed Apr 10, 2019
1 parent 40422ac commit f6bd68d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
25 changes: 25 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
"globals": {
'ts-jest': {
"tsConfig": 'tsconfig.test.json'
}
},
"roots": [
"tests"
],
"transform": {
"^.+\\.(ts|tsx)?$": "ts-jest"
},
"moduleNameMapper": {
"\\.(scss|html)$": "<rootDir>/tests/empty-module.js"
},
"testRegex": "(/tests/.*|(\\.|/)(test|spec))\\.(ts|tsx)?$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"scripts": {
"start": "npm run build_dev && live-server --port=7777",
"serve": "live-server --port=7777",
"test": "jest",
"testDev": "jest --watch",
"release": "standard-version --message \"Release: %s\" ",
"build_dev": "webpack --env.buildType dev --env.platform pdf",
"build_prod": "npm run build_dev && webpack --env.buildType prod --env.platform pdf"
Expand All @@ -10,6 +12,7 @@
"name": "survey-pdf",
"private": true,
"devDependencies": {
"@types/jest": "^23.3.3",
"@types/jspdf": "^1.2.2",
"@types/lodash": "4.14.121",
"@types/node": "7.0.4",
Expand All @@ -23,6 +26,7 @@
"github-api": "^3.0.0",
"html-loader": "0.4.4",
"http-server": "0.9.0",
"jest": "^23.6.0",
"jspdf": "git+https://github.com/MrRio/jsPDF.git",
"live-server": "1.2.0",
"node-uuid": "1.4.7",
Expand All @@ -33,6 +37,7 @@
"standard-version": "4.0.0",
"style-loader": "0.13.1",
"survey-core": "^1.0.78",
"ts-jest": "^23.10.3",
"ts-loader": "2.3.4",
"tslint": "4.5.1",
"typescript": "2.6.1",
Expand Down
6 changes: 6 additions & 0 deletions tests/common.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { JsPdfSurveyModel } from "../src/jspdf/survey";

test("first", () => {
let survey = new JsPdfSurveyModel({});
expect(survey).toBeDefined();
});
1 change: 1 addition & 0 deletions tests/empty-module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = '';
23 changes: 23 additions & 0 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"lib": [
"DOM",
"ES5",
"ES2015.Promise"
],
"sourceMap": true,
"noImplicitAny": true,
"importHelpers": false,
"experimentalDecorators": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true
},
"exclude": [
"src/entries/**/*.ts"
],
"include": [
"src/**/*.ts"
]
}

0 comments on commit f6bd68d

Please sign in to comment.