Skip to content

Commit ec62357

Browse files
authored
Merge pull request #1294 from ml5js/joeyklee.637-migrate-to-jest
refactor(#637): Migrate testing utilities to Jest pt.1/X
2 parents e616a57 + 2ac3f72 commit ec62357

File tree

9 files changed

+18195
-13504
lines changed

9 files changed

+18195
-13504
lines changed

.babelrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"presets": [
3+
"@babel/preset-env"
4+
],
5+
"plugins": [
6+
[
7+
"@babel/plugin-transform-runtime",
8+
{
9+
"corejs": 3,
10+
"version": "^7.11.2"
11+
}
12+
]
13+
]
14+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ website/i18n/*
2424

2525
yarn-error.log
2626
local.log
27+
28+
coverage/*

jest.config.js

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
/*
2+
* For a detailed explanation regarding each configuration property, visit:
3+
* https://jestjs.io/docs/configuration
4+
*/
5+
6+
module.exports = {
7+
testTimeout: 100000,
8+
// All imported modules in your tests should be mocked automatically
9+
// automock: false,
10+
11+
// Stop running tests after `n` failures
12+
// bail: 0,
13+
14+
// The directory where Jest should store its cached dependency information
15+
// cacheDirectory: "/private/var/folders/97/3b694kz90kb0tq9qgz512y_h0000gp/T/jest_dy",
16+
17+
// Automatically clear mock calls, instances and results before every test
18+
// clearMocks: false,
19+
20+
// Indicates whether the coverage information should be collected while executing the test
21+
collectCoverage: true,
22+
23+
// An array of glob patterns indicating a set of files for which coverage information should be collected
24+
// collectCoverageFrom: undefined,
25+
26+
// The directory where Jest should output its coverage files
27+
coverageDirectory: "coverage",
28+
29+
// An array of regexp pattern strings used to skip coverage collection
30+
coveragePathIgnorePatterns: ["/node_modules/"],
31+
32+
// Indicates which provider should be used to instrument code for coverage
33+
// coverageProvider: "babel",
34+
35+
// A list of reporter names that Jest uses when writing coverage reports
36+
// coverageReporters: [
37+
// "json",
38+
// "text",
39+
// "lcov",
40+
// "clover"
41+
// ],
42+
43+
// An object that configures minimum threshold enforcement for coverage results
44+
// coverageThreshold: undefined,
45+
46+
// A path to a custom dependency extractor
47+
// dependencyExtractor: undefined,
48+
49+
// Make calling deprecated APIs throw helpful error messages
50+
// errorOnDeprecated: false,
51+
52+
// Force coverage collection from ignored files using an array of glob patterns
53+
// forceCoverageMatch: [],
54+
55+
// A path to a module which exports an async function that is triggered once before all test suites
56+
// globalSetup: undefined,
57+
58+
// A path to a module which exports an async function that is triggered once after all test suites
59+
// globalTeardown: undefined,
60+
61+
// A set of global variables that need to be available in all test environments
62+
// globals: {},
63+
64+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
65+
// maxWorkers: "50%",
66+
67+
// An array of directory names to be searched recursively up from the requiring module's location
68+
// moduleDirectories: ["node_modules"],
69+
70+
// An array of file extensions your modules use
71+
moduleFileExtensions: ["js", "jsx", "ts", "tsx", "json", "node"],
72+
73+
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
74+
// moduleNameMapper: {},
75+
76+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
77+
// modulePathIgnorePatterns: [],
78+
79+
// Activates notifications for test results
80+
// notify: false,
81+
82+
// An enum that specifies notification mode. Requires { notify: true }
83+
// notifyMode: "failure-change",
84+
85+
// A preset that is used as a base for Jest's configuration
86+
// preset: undefined,
87+
88+
// Run tests from one or more projects
89+
// projects: undefined,
90+
91+
// Use this configuration option to add custom reporters to Jest
92+
// reporters: undefined,
93+
94+
// Automatically reset mock state before every test
95+
// resetMocks: false,
96+
97+
// Reset the module registry before running each individual test
98+
// resetModules: false,
99+
100+
// A path to a custom resolver
101+
// resolver: undefined,
102+
103+
// Automatically restore mock state and implementation before every test
104+
// restoreMocks: false,
105+
106+
// The root directory that Jest should scan for tests and modules within
107+
// rootDir: undefined,
108+
109+
// A list of paths to directories that Jest should use to search for files in
110+
// roots: [
111+
// "<rootDir>"
112+
// ],
113+
114+
// Allows you to use a custom runner instead of Jest's default test runner
115+
// runner: "jest-runner",
116+
117+
// The paths to modules that run some code to configure or set up the testing environment before each test
118+
setupFiles: ["jest-canvas-mock"],
119+
120+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
121+
// setupFilesAfterEnv: [],
122+
123+
// The number of seconds after which a test is considered as slow and reported as such in the results.
124+
// slowTestThreshold: 5,
125+
126+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
127+
// snapshotSerializers: [],
128+
129+
// The test environment that will be used for testing
130+
testEnvironment: "jsdom",
131+
132+
// Options that will be passed to the testEnvironment
133+
// testEnvironmentOptions: {},
134+
135+
// Adds a location field to test results
136+
// testLocationInResults: false,
137+
138+
// The glob patterns Jest uses to detect test files
139+
// testMatch: [
140+
// "**/__tests__/**/*.[jt]s?(x)",
141+
// "**/?(*.)+(spec|test).[tj]s?(x)"
142+
// ],
143+
144+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
145+
// testPathIgnorePatterns: [
146+
// "/node_modules/"
147+
// ],
148+
149+
// The regexp pattern or array of patterns that Jest uses to detect test files
150+
// testRegex: [],
151+
152+
// This option allows the use of a custom results processor
153+
// testResultsProcessor: undefined,
154+
155+
// This option allows use of a custom test runner
156+
// testRunner: "jest-circus/runner",
157+
158+
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
159+
// testURL: "http://localhost",
160+
161+
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
162+
// timers: "real",
163+
164+
// A map from regular expressions to paths to transformers
165+
// transform: undefined,
166+
167+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
168+
// transformIgnorePatterns: [
169+
// "/node_modules/",
170+
// "\\.pnp\\.[^\\/]+$"
171+
// ],
172+
173+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
174+
// unmockedModulePathPatterns: undefined,
175+
176+
// Indicates whether each individual test should be reported during the run
177+
// verbose: undefined,
178+
179+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
180+
// watchPathIgnorePatterns: [],
181+
182+
// Whether to use watchman for file crawling
183+
// watchman: true,
184+
};

0 commit comments

Comments
 (0)