Skip to content

Commit ebe903d

Browse files
committed
setup for tests: initial setup
1 parent 5ace418 commit ebe903d

25 files changed

Lines changed: 513 additions & 26 deletions

jest.config.js

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

package-lock.json

Lines changed: 78 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"updateVersion": "webpack --env joplin-plugin-config=updateVersion",
88
"update": "npm install -g generator-joplin && yo joplin --node-package-manager npm --update --force",
99
"build-docs": "typedoc --options typedoc.json && npm exec --package=@atao60/fse-cli fse copy ./img ./docs/img",
10-
"test": "vitest --root './tests' --run --reporter verbose --environment jsdom",
10+
"test": "vitest --root './tests' --run --reporter verbose",
1111
"jtest": "jest"
1212
},
1313
"license": "MIT",
@@ -27,6 +27,7 @@
2727
"easyui": "^8.0.0",
2828
"fs-extra": "^10.1.0",
2929
"glob": "^8.0.3",
30+
"inversify": "^7.5.1",
3031
"jest": "^29.7.0",
3132
"path": "^0.12.7",
3233
"tar": "^6.1.11",

src/assets/js/bootLoader.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,8 @@ kihBootLoader.init1()
347347
console.error(`Error ${err} `, err);
348348
kihBootLoader.fatal(err);
349349
});
350+
351+
// This helps to import symbols in test suite
352+
try {
353+
module.exports = BootLoader;
354+
} catch(e) { }

src/assets/js/categoriesTree.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,3 +826,8 @@ class CategoriesTree {
826826
return this.tree.tree('find', { text: node.text });
827827
}
828828
}
829+
830+
// This helps to import symbols in test suite
831+
try {
832+
module.exports = CategoriesTree;
833+
} catch(e) { }

src/assets/js/di/inversifyjs.min.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/js/dialog.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,3 +1627,8 @@ class KatexInputHelper {
16271627
}
16281628
}
16291629

1630+
// This helps to import symbols in test suite
1631+
try {
1632+
module.exports = KatexInputHelper;
1633+
} catch(e) { }
1634+

src/assets/js/fileHandling.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,8 @@ class FileHandler {
130130
return;
131131
}
132132
}
133+
134+
// This helps to import symbols in test suite
135+
try {
136+
module.exports = FileHandler;
137+
} catch(e) { }

src/assets/js/helpers.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,8 @@ class Utilities {
8989
return html;
9090
}
9191
}
92+
93+
// This helps to import symbols in test suite
94+
try {
95+
module.exports = { Messager, Utilities };
96+
} catch(e) { }

0 commit comments

Comments
 (0)