Skip to content

Commit

Permalink
Configuring jest environments
Browse files Browse the repository at this point in the history
  • Loading branch information
zourdyzou committed Jun 26, 2022
1 parent 88d18bf commit 1608082
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
dist/
dist/
.idea/
32 changes: 32 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const path = require("path");

module.exports = {
clearMocks: true,
restoreMocks: true,
collectCoverage: true,
collectCoverageFrom: [path.resolve(__dirname, "src/**/*.{js,jsx,ts,tsx}")],
coverageDirectory: "coverage",
coverageReporters: ["text-summary", "lcov"],
coverageThreshold: {
global: {
branches: 95,
functions: 99,
lines: 99,
statements: 95,
},
},
errorOnDeprecated: true,
moduleNameMapper: {
"\\.(jpg|jpeg|png|gif|webp|svg|bmp|woff|woff2|ttf)$": "<rootDir>/test/mocks/fileMock.js",
"\\.(css|less|scss|sass)$": "identity-obj-proxy",
"test/(.*)$": "<rootDir>/test/$1",
"~/(.*)$": "<rootDir>/src/$1",
},
setupFilesAfterEnv: ["<rootDir>/test/setup.ts"],
globalTeardown: "<rootDir>/test/teardown.ts",
fakeTimers: {
enableGlobally: true,
},
verbose: true,
testEnvironment: "jsdom",
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build:prod": "webpack --mode=production --node-env=production",
"watch": "webpack --watch --mode=development",
"serve": "webpack serve --mode=development",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest"
},
"directories": {
"example": "examples"
Expand Down
11 changes: 11 additions & 0 deletions src/helpers/Field.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export type Cell = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
export type Field = Cell[][];
export type Coordinates = [number, number];

export const CellState: Record<string, Cell> = {
empty: 0,
bomb: 9,
hidden: 10,
mark: 11,
weakMark: 12,
};

0 comments on commit 1608082

Please sign in to comment.