Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Commit 57a93bc

Browse files
authored
Merge pull request #1 from reactioncommerce/tests-kieckhafer-addUnitTestToPlugin
tests: add test to plugin
2 parents 7597d4e + 2f97861 commit 57a93bc

File tree

7 files changed

+6750
-1964
lines changed

7 files changed

+6750
-1964
lines changed

.circleci/config.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ jobs:
4848

4949
- run: npm run lint
5050

51+
test:
52+
docker:
53+
- image: node:12
54+
55+
steps:
56+
- checkout
57+
58+
- restore_cache:
59+
keys:
60+
- v1-dependencies-{{ checksum "package.json" }}
61+
# fallback to using the latest cache if no exact match is found
62+
- v1-dependencies-
63+
64+
- run: npm run test
65+
5166
workflows:
5267
version: 2
5368
build_deploy:
@@ -57,10 +72,14 @@ workflows:
5772
- lint:
5873
requires:
5974
- build
75+
- test:
76+
requires:
77+
- build
6078
- deploy:
6179
context: reaction-publish-semantic-release
6280
requires:
6381
- lint
82+
- test
6483
filters:
6584
branches:
6685
only: trunk

babel.config.cjs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Babel is used only for running Jest tests in this project.
3+
* If Jest adds support for ESM and import.meta, then Babel
4+
* may become unnecessary.
5+
*/
6+
7+
module.exports = function (api) { // eslint-disable-line no-undef
8+
api.cache(false);
9+
10+
return {
11+
presets: [
12+
[
13+
"@babel/preset-env",
14+
{
15+
targets: {
16+
node: "12"
17+
}
18+
}
19+
]
20+
],
21+
plugins: [
22+
"babel-plugin-transform-import-meta",
23+
"module:@reactioncommerce/babel-remove-es-create-require",
24+
"rewire-exports",
25+
"transform-es2015-modules-commonjs"
26+
]
27+
};
28+
};

jest.config.cjs

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

0 commit comments

Comments
 (0)