mirror of
https://github.com/usatiuk/writer.git
synced 2025-10-28 16:07:49 +01:00
setup jest for frontend testing
This commit is contained in:
10
frontend/jest.config.js
Normal file
10
frontend/jest.config.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const { pathsToModuleNameMapper } = require("ts-jest/utils");
|
||||
const { compilerOptions } = require("./tsconfig");
|
||||
|
||||
module.exports = {
|
||||
preset: "ts-jest",
|
||||
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
|
||||
prefix: "<rootDir>/",
|
||||
}),
|
||||
setupFilesAfterEnv: ["<rootDir>/src/setupTests.ts"],
|
||||
};
|
||||
2556
frontend/package-lock.json
generated
2556
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -3,9 +3,13 @@
|
||||
"scripts": {
|
||||
"start": "parcel src/index.html",
|
||||
"build": "parcel build src/index.html",
|
||||
"test": "echo \"Error: no tests (yet!)\""
|
||||
"test": "jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/autoprefixer": "^9.4.0",
|
||||
"@types/enzyme": "^3.9.0",
|
||||
"@types/enzyme-adapter-react-16": "^1.0.5",
|
||||
"@types/jest": "^24.0.11",
|
||||
"@types/node-sass": "^3.10.32",
|
||||
"@types/parcel-bundler": "^1.10.1",
|
||||
"@types/react": "^16.8.2",
|
||||
@@ -14,10 +18,14 @@
|
||||
"@types/react-router": "^4.4.3",
|
||||
"@types/react-router-dom": "^4.3.1",
|
||||
"autoprefixer": "^9.4.7",
|
||||
"enzyme": "^3.9.0",
|
||||
"enzyme-adapter-react-16": "^1.10.0",
|
||||
"jest": "^24.3.1",
|
||||
"node-sass": "^4.11.0",
|
||||
"parcel-bundler": "^1.11.0",
|
||||
"postcss-modules": "^1.4.1",
|
||||
"redux-devtools-extension": "^2.13.8"
|
||||
"redux-devtools-extension": "^2.13.8",
|
||||
"ts-jest": "^24.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blueprintjs/core": "^3.13.0",
|
||||
|
||||
17
frontend/src/Documents/tests/DocumentsList.test.tsx
Normal file
17
frontend/src/Documents/tests/DocumentsList.test.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import { shallow } from "enzyme";
|
||||
import * as React from "react";
|
||||
|
||||
import { NewDocumentCard } from "~Documents/NewDocumentCard";
|
||||
import { DocumentsList } from "../DocumentsList";
|
||||
|
||||
describe("<DocumentsList />", () => {
|
||||
it("should render NewDocumentCard if newDocument prop is true", () => {
|
||||
const wrapper = shallow(<DocumentsList docs={[]} newDocument={true} />);
|
||||
expect(wrapper.find(NewDocumentCard)).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("should render NewDocumentCard if newDocument prop is undefined", () => {
|
||||
const wrapper = shallow(<DocumentsList docs={[]} />);
|
||||
expect(wrapper.find(NewDocumentCard)).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
4
frontend/src/setupTests.ts
Normal file
4
frontend/src/setupTests.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import * as Enzyme from "enzyme";
|
||||
import * as Adapter from "enzyme-adapter-react-16";
|
||||
|
||||
Enzyme.configure({ adapter: new Adapter() });
|
||||
@@ -14,10 +14,10 @@
|
||||
"sourceMap": true,
|
||||
"noImplicitAny": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"baseUrl": "./src",
|
||||
"baseUrl": "./",
|
||||
"paths": {
|
||||
"~*": [
|
||||
"./*"
|
||||
"./src/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user