@papillonarts/setup 0.48.0 → 0.49.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/build/babel/index.d.ts +3 -1
- package/build/babel/index.js +6 -1
- package/build/eslint/index.d.mts +3 -2
- package/build/eslint/index.d.mts.map +1 -1
- package/build/eslint/index.mjs +27 -10
- package/build/jest/config.d.ts +9 -5
- package/build/jest/config.d.ts.map +1 -1
- package/build/jest/config.js +19 -20
- package/build/jest/index.js +6 -6
- package/build/jest/setup.d.ts.map +1 -1
- package/build/jest/setup.js +38 -44
- package/build/jest/utility.js +16 -87
- package/build/storybook/index.js +3 -3
- package/build/storybook/mainSetup.d.ts.map +1 -1
- package/build/storybook/mainSetup.js +104 -104
- package/build/storybook/managerSetup.js +5 -4
- package/build/storybook/previewSetup.js +6 -3
- package/build/stylelint/index.d.ts +1 -0
- package/build/stylelint/index.js +4 -1
- package/build/webpack/constant/index.d.ts +0 -1
- package/build/webpack/constant/index.d.ts.map +1 -1
- package/build/webpack/constant/index.js +6 -7
- package/build/webpack/index.js +31 -31
- package/build/webpack/loader/babelLoader.d.ts +3 -2
- package/build/webpack/loader/babelLoader.d.ts.map +1 -1
- package/build/webpack/loader/babelLoader.js +8 -3
- package/build/webpack/loader/cssLoader.js +8 -7
- package/build/webpack/loader/postCSSLoader.js +1 -3
- package/build/webpack/loader/sassLoader.js +4 -3
- package/build/webpack/plugin/bannerPlugin.js +3 -3
- package/build/webpack/plugin/cleanWebpackPlugin.js +16 -15
- package/build/webpack/plugin/copyWebpackPlugin.js +8 -7
- package/build/webpack/plugin/cssMinimizerWebpackPlugin.js +2 -2
- package/build/webpack/plugin/dotenvWebpack.d.ts +3 -2
- package/build/webpack/plugin/dotenvWebpack.d.ts.map +1 -1
- package/build/webpack/plugin/dotenvWebpack.js +23 -21
- package/build/webpack/plugin/forkTSCheckerWebpackPlugin.js +2 -2
- package/build/webpack/plugin/hotModuleReplacementPlugin.js +2 -2
- package/build/webpack/plugin/htmlWebpackPlugin.js +23 -21
- package/build/webpack/plugin/miniCSSExtractPlugin.js +4 -4
- package/build/webpack/plugin/moduleConcatenationPlugin.js +2 -2
- package/build/webpack/plugin/webpackManifestPlugin.js +1 -1
- package/build/webpack/setup/commonSetup.d.ts +3 -2
- package/build/webpack/setup/commonSetup.d.ts.map +1 -1
- package/build/webpack/setup/commonSetup.js +6 -5
- package/build/webpack/setup/developmentSetup.js +7 -6
- package/build/webpack/setup/productionSetup.js +7 -6
- package/package.json +12 -12
package/LICENSE
CHANGED
package/build/babel/index.d.ts
CHANGED
package/build/babel/index.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
-
|
|
4
|
+
// https://babeljs.io/docs/babel-preset-env#modules
|
|
5
|
+
// Babel 8 no longer defaults to CommonJS output; this config builds package "main"/build
|
|
6
|
+
// output (via generate-commonjs) and transforms Jest test files, both of which need require().
|
|
7
|
+
presets: [['@babel/preset-env', {
|
|
8
|
+
modules: 'commonjs'
|
|
9
|
+
}], '@babel/preset-react', '@babel/preset-typescript'],
|
|
5
10
|
plugins: [['@babel/plugin-transform-react-jsx', {
|
|
6
11
|
runtime: 'automatic'
|
|
7
12
|
}], '@babel/plugin-transform-runtime', 'syntax-async-functions']
|
package/build/eslint/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export function getESLintSetup({ eslintIgnores }: {
|
|
1
|
+
export function getESLintSetup({ eslintIgnores, languageOptionsParserOptionsProject }: {
|
|
2
2
|
eslintIgnores: any;
|
|
3
|
-
|
|
3
|
+
languageOptionsParserOptionsProject: any;
|
|
4
|
+
}): import("eslint/config").ConfigObject[];
|
|
4
5
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/eslint/index.mjs"],"names":[],"mappings":"AAwBA
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/eslint/index.mjs"],"names":[],"mappings":"AAwBA;;;2CAsLC"}
|
package/build/eslint/index.mjs
CHANGED
|
@@ -22,7 +22,31 @@ const compat = new FlatCompat({
|
|
|
22
22
|
allConfig: js.configs.all,
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
-
export function getESLintSetup({ eslintIgnores }) {
|
|
25
|
+
export function getESLintSetup({ eslintIgnores, languageOptionsParserOptionsProject }) {
|
|
26
|
+
let parserOptions = {
|
|
27
|
+
ecmaFeatures: {
|
|
28
|
+
jsx: true,
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!languageOptionsParserOptionsProject) {
|
|
33
|
+
parserOptions = {
|
|
34
|
+
...parserOptions,
|
|
35
|
+
|
|
36
|
+
// https://typescript-eslint.io/packages/parser/#projectservice
|
|
37
|
+
projectService: {
|
|
38
|
+
allowDefaultProject: ['*.js', '*.jsx', '*.ts', '*.tsx', '*.d.ts'],
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
parserOptions = {
|
|
43
|
+
...parserOptions,
|
|
44
|
+
|
|
45
|
+
// https://typescript-eslint.io/packages/parser/#project
|
|
46
|
+
project: languageOptionsParserOptionsProject,
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
26
50
|
return defineConfig([
|
|
27
51
|
globalIgnores(eslintIgnores),
|
|
28
52
|
{
|
|
@@ -89,15 +113,7 @@ export function getESLintSetup({ eslintIgnores }) {
|
|
|
89
113
|
ecmaVersion: 'latest',
|
|
90
114
|
sourceType: 'module',
|
|
91
115
|
|
|
92
|
-
parserOptions
|
|
93
|
-
ecmaFeatures: {
|
|
94
|
-
jsx: true,
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
projectService: {
|
|
98
|
-
allowDefaultProject: ['*.js', '*.jsx', '*.ts', '*.tsx', '*.d.ts'],
|
|
99
|
-
},
|
|
100
|
-
},
|
|
116
|
+
parserOptions,
|
|
101
117
|
},
|
|
102
118
|
|
|
103
119
|
settings: {
|
|
@@ -180,6 +196,7 @@ export function getESLintSetup({ eslintIgnores }) {
|
|
|
180
196
|
'comma-dangle': 0,
|
|
181
197
|
'no-unused-vars': 'off',
|
|
182
198
|
'@typescript-eslint/no-unused-vars': 'error',
|
|
199
|
+
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports', fixStyle: 'separate-type-imports' }],
|
|
183
200
|
// Testing Library rules
|
|
184
201
|
'testing-library/prefer-screen-queries': 'error',
|
|
185
202
|
'testing-library/prefer-presence-queries': 'error',
|
package/build/jest/config.d.ts
CHANGED
|
@@ -10,9 +10,6 @@ export declare function getJestSetup({ testPathIgnorePatterns, coverageDirectory
|
|
|
10
10
|
globals?: {
|
|
11
11
|
[x: string]: unknown;
|
|
12
12
|
};
|
|
13
|
-
cache?: boolean;
|
|
14
|
-
resolver?: string;
|
|
15
|
-
roots?: string[];
|
|
16
13
|
bail?: number | boolean;
|
|
17
14
|
testPathIgnorePatterns?: string[];
|
|
18
15
|
coverageDirectory?: string;
|
|
@@ -33,11 +30,13 @@ export declare function getJestSetup({ testPathIgnorePatterns, coverageDirectory
|
|
|
33
30
|
}>>;
|
|
34
31
|
};
|
|
35
32
|
automock?: boolean;
|
|
33
|
+
cache?: boolean;
|
|
36
34
|
cacheDirectory?: string;
|
|
37
35
|
ci?: boolean;
|
|
38
36
|
clearMocks?: boolean;
|
|
39
37
|
changedFilesWithAncestor?: boolean;
|
|
40
38
|
changedSince?: string;
|
|
39
|
+
collectTests?: boolean;
|
|
41
40
|
coveragePathIgnorePatterns?: string[];
|
|
42
41
|
coverageProvider?: "babel" | "v8";
|
|
43
42
|
coverageReporters?: ("text" | "json" | "clover" | "cobertura" | "html-spa" | "html" | "json-summary" | "lcov" | "lcovonly" | "none" | "teamcity" | "text-lcov" | "text-summary" | ["text" | "json" | "clover" | "cobertura" | "html-spa" | "html" | "json-summary" | "lcov" | "lcovonly" | "none" | "teamcity" | "text-lcov" | "text-summary", {
|
|
@@ -56,7 +55,7 @@ export declare function getJestSetup({ testPathIgnorePatterns, coverageDirectory
|
|
|
56
55
|
enableGlobally?: boolean;
|
|
57
56
|
} & ({
|
|
58
57
|
advanceTimers?: number | boolean;
|
|
59
|
-
doNotFake?: ("
|
|
58
|
+
doNotFake?: ("queueMicrotask" | "setImmediate" | "performance" | "Date" | "hrtime" | "nextTick" | "requestAnimationFrame" | "cancelAnimationFrame" | "requestIdleCallback" | "cancelIdleCallback" | "clearImmediate" | "setInterval" | "clearInterval" | "setTimeout" | "clearTimeout" | "Temporal")[];
|
|
60
59
|
now?: number;
|
|
61
60
|
timerLimit?: number;
|
|
62
61
|
legacyFakeTimers?: false;
|
|
@@ -114,9 +113,13 @@ export declare function getJestSetup({ testPathIgnorePatterns, coverageDirectory
|
|
|
114
113
|
replname?: string;
|
|
115
114
|
resetMocks?: boolean;
|
|
116
115
|
resetModules?: boolean;
|
|
116
|
+
resolver?: string;
|
|
117
117
|
restoreMocks?: boolean;
|
|
118
118
|
rootDir?: string;
|
|
119
|
-
|
|
119
|
+
roots?: string[];
|
|
120
|
+
runner?: string | [string, {
|
|
121
|
+
[x: string]: unknown;
|
|
122
|
+
}];
|
|
120
123
|
runTestsByPath?: boolean;
|
|
121
124
|
runtime?: string;
|
|
122
125
|
sandboxInjectedGlobals?: string[];
|
|
@@ -179,5 +182,6 @@ export declare function getJestSetup({ testPathIgnorePatterns, coverageDirectory
|
|
|
179
182
|
watchPlugins?: (string | [string, unknown])[];
|
|
180
183
|
workerIdleMemoryLimit?: string | number;
|
|
181
184
|
workerThreads?: boolean;
|
|
185
|
+
workerGracefulExitTimeout?: number;
|
|
182
186
|
};
|
|
183
187
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/jest/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/jest/config.ts"],"names":[],"mappings":"AAyGA,eAAO,MAAM,uBAAuB,UAAyD,CAAA;AAE7F,wBAAgB,YAAY,CAAC,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,EAAE;;;;;;CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BlI"}
|
package/build/jest/config.js
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.getJestSetup = getJestSetup;
|
|
8
7
|
exports.transformIgnorePatterns = void 0;
|
|
9
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
8
|
var _jestConfig = require("jest-config");
|
|
11
9
|
// https://jestjs.io/docs/configuration
|
|
12
10
|
// https://jestjs.io/docs/getting-started#using-typescript
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function getJestSetup(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
const transformIgnorePackages = ['@asamuzakjp', '@csstools', '@exodus', 'bail', 'ccount', 'character-entities', 'character-entities-legacy', 'character-reference-invalid', 'comma-separated-tokens', 'decode-named-character-reference', 'devlop', 'entities', 'escape-string-regexp', 'estree-util-is-identifier-name', 'hast-util-parse-selector', 'hast-util-to-jsx-runtime', 'hast-util-whitespace', 'hastscript', 'html-url-attributes', 'is-alphabetical', 'is-alphanumerical', 'is-blank', 'is-decimal', 'is-hexadecimal', 'is-plain-obj', 'is-whitespace-like', 'jsdom/node_modules/(parse5|entities)', 'longest-streak', 'markdown-table', 'mdast-util-find-and-replace', 'mdast-util-find-and-replace/node_modules/escape-string-regexp', 'mdast-util-from-markdown', 'mdast-util-gfm', 'mdast-util-gfm-autolink-literal', 'mdast-util-gfm-footnote', 'mdast-util-gfm-strikethrough', 'mdast-util-gfm-table', 'mdast-util-gfm-task-list-item', 'mdast-util-mdx-expression', 'mdast-util-mdx-jsx', 'mdast-util-mdxjs-esm', 'mdast-util-phrasing', 'mdast-util-to-hast', 'mdast-util-to-markdown', 'mdast-util-to-string', 'micromark', 'micromark-core-commonmark', 'micromark-extension-gfm', 'micromark-extension-gfm-autolink-literal', 'micromark-extension-gfm-footnote', 'micromark-extension-gfm-strikethrough', 'micromark-extension-gfm-table', 'micromark-extension-gfm-tagfilter', 'micromark-extension-gfm-task-list-item', 'micromark-factory-destination', 'micromark-factory-label', 'micromark-factory-space', 'micromark-factory-title', 'micromark-factory-whitespace', 'micromark-util-character', 'micromark-util-chunked', 'micromark-util-classify-character', 'micromark-util-combine-extensions', 'micromark-util-decode-numeric-character-reference', 'micromark-util-decode-string', 'micromark-util-encode', 'micromark-util-html-tag-name', 'micromark-util-normalize-identifier', 'micromark-util-resolve-all', 'micromark-util-sanitize-uri', 'micromark-util-subtokenize', 'micromark-util-symbol', 'micromark-util-types', 'parse-entities', 'parse5', 'property-information', 'react-markdown', 'react-syntax-highlighter', 'refractor', 'remark-gfm', 'remark-parse', 'remark-rehype', 'remark-stringify', 'space-separated-tokens', 'trim-lines', 'trough', 'unified', 'unified/node_modules/is-plain-obj', 'unist-util-is', 'unist-util-position', 'unist-util-stringify-position', 'unist-util-visit', 'unist-util-visit-parents', 'uuid', 'vfile', 'vfile-message', 'zwitch'].join('|');
|
|
13
|
+
const transformIgnorePatterns = exports.transformIgnorePatterns = [`node_modules/(?!((@)?${transformIgnorePackages})/)`];
|
|
14
|
+
function getJestSetup({
|
|
15
|
+
testPathIgnorePatterns,
|
|
16
|
+
coverageDirectory,
|
|
17
|
+
collectCoverage,
|
|
18
|
+
collectCoverageFrom,
|
|
19
|
+
coverageThreshold
|
|
20
|
+
}) {
|
|
21
|
+
const config = {
|
|
23
22
|
testMatch: ['**/?(*.)test.(js|ts)?(x)'],
|
|
24
|
-
testPathIgnorePatterns
|
|
23
|
+
testPathIgnorePatterns,
|
|
25
24
|
roots: ['<rootDir>'],
|
|
26
25
|
transform: {
|
|
27
|
-
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest'
|
|
26
|
+
'^.+\\.(js|jsx|mjs|ts|tsx)$': 'babel-jest'
|
|
28
27
|
},
|
|
29
|
-
coverageDirectory
|
|
30
|
-
collectCoverage
|
|
28
|
+
coverageDirectory,
|
|
29
|
+
collectCoverage,
|
|
31
30
|
coverageReporters: ['lcov', 'text'],
|
|
32
|
-
collectCoverageFrom
|
|
31
|
+
collectCoverageFrom,
|
|
33
32
|
// https://jest-extended.jestcommunity.dev/docs/getting-started/setup
|
|
34
33
|
// https://jest-extended.jestcommunity.dev/docs/matchers
|
|
35
34
|
setupFilesAfterEnv: ['@testing-library/jest-dom', '<rootDir>/jest.setup.js', 'jest-extended/all'],
|
|
@@ -38,13 +37,13 @@ function getJestSetup(_ref) {
|
|
|
38
37
|
'^.+\\.(css|less|scss|md)$': 'identity-obj-proxy'
|
|
39
38
|
},
|
|
40
39
|
// https://jestjs.io/docs/tutorial-react-native#transformignorepatterns-customization
|
|
41
|
-
transformIgnorePatterns
|
|
42
|
-
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
|
|
43
|
-
coverageThreshold
|
|
40
|
+
transformIgnorePatterns,
|
|
41
|
+
moduleFileExtensions: ['js', 'jsx', 'mjs', 'ts', 'tsx'],
|
|
42
|
+
coverageThreshold,
|
|
44
43
|
// https://github.com/storybookjs/addon-jest
|
|
45
44
|
modulePathIgnorePatterns: ['<rootDir>/node_modules', '<rootDir>/jest-test-results.json'],
|
|
46
45
|
// https://jestjs.io/docs/configuration#moduledirectories-arraystring
|
|
47
|
-
moduleDirectories:
|
|
46
|
+
moduleDirectories: [..._jestConfig.defaults.moduleDirectories]
|
|
48
47
|
};
|
|
49
48
|
return config;
|
|
50
49
|
}
|
package/build/jest/index.js
CHANGED
|
@@ -5,37 +5,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "createMockStore", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _utility.createMockStore;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "getJestSetup", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function
|
|
14
|
+
get: function () {
|
|
15
15
|
return _config.getJestSetup;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "renderSnapshot", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function
|
|
20
|
+
get: function () {
|
|
21
21
|
return _utility.renderSnapshot;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "renderSnapshotAsync", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function
|
|
26
|
+
get: function () {
|
|
27
27
|
return _utility.renderSnapshotAsync;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "runJestSetup", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function
|
|
32
|
+
get: function () {
|
|
33
33
|
return _setup.runJestSetup;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "waitFor", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function
|
|
38
|
+
get: function () {
|
|
39
39
|
return _utility.waitFor;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/jest/setup.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/jest/setup.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,CAAA;AAYhB,wBAAgB,YAAY,SAoH3B"}
|
package/build/jest/setup.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.runJestSetup = runJestSetup;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
7
|
require("./jsdom");
|
|
11
8
|
var _react = require("@testing-library/react");
|
|
12
9
|
var _jestAxe = require("jest-axe");
|
|
10
|
+
var _nodeBuffer = require("node:buffer");
|
|
13
11
|
var _snapshotDiff = require("snapshot-diff");
|
|
14
12
|
// https://github.com/jest-community/snapshot-diff
|
|
15
13
|
// IMPORTANT: jsdom-global MUST be imported first to set up global document before testing-library imports
|
|
16
14
|
|
|
15
|
+
// jsdom-global copies jsdom's window.atob/btoa onto the Node global, but those just
|
|
16
|
+
// delegate to the ambient global atob/btoa — once copied, that delegation becomes
|
|
17
|
+
// self-referential and throws/overflows. Restore Node's real implementations.
|
|
18
|
+
global.atob = _nodeBuffer.atob;
|
|
19
|
+
global.btoa = _nodeBuffer.btoa;
|
|
17
20
|
function runJestSetup() {
|
|
18
21
|
/**
|
|
19
22
|
* Normalizes Date.prototype methods to output deterministic ISO-like UTC strings.
|
|
@@ -35,7 +38,7 @@ function runJestSetup() {
|
|
|
35
38
|
* @returns {string} Padded string
|
|
36
39
|
*/
|
|
37
40
|
function pad2(n) {
|
|
38
|
-
return n < 10 ?
|
|
41
|
+
return n < 10 ? `0${n}` : `${n}`;
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
/**
|
|
@@ -44,13 +47,13 @@ function runJestSetup() {
|
|
|
44
47
|
* @returns {string} Formatted ISO-like date-time string
|
|
45
48
|
*/
|
|
46
49
|
function formatAsISODateTime(date) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return
|
|
50
|
+
const d = pad2(date.getUTCDate());
|
|
51
|
+
const m = pad2(date.getUTCMonth() + 1);
|
|
52
|
+
const y = date.getUTCFullYear();
|
|
53
|
+
const hh = pad2(date.getUTCHours());
|
|
54
|
+
const mm = pad2(date.getUTCMinutes());
|
|
55
|
+
const ss = pad2(date.getUTCSeconds());
|
|
56
|
+
return `${y}-${m}-${d}T${hh}:${mm}:${ss}Z`;
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
/**
|
|
@@ -59,10 +62,10 @@ function runJestSetup() {
|
|
|
59
62
|
* @returns {string} Formatted ISO-like date string
|
|
60
63
|
*/
|
|
61
64
|
function formatAsISODate(date) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return
|
|
65
|
+
const d = pad2(date.getUTCDate());
|
|
66
|
+
const m = pad2(date.getUTCMonth() + 1);
|
|
67
|
+
const y = date.getUTCFullYear();
|
|
68
|
+
return `${y}-${m}-${d}`;
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
/**
|
|
@@ -71,14 +74,14 @@ function runJestSetup() {
|
|
|
71
74
|
* @returns {string} Formatted ISO-like time string
|
|
72
75
|
*/
|
|
73
76
|
function formatAsISOTime(date) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return
|
|
77
|
+
const hh = pad2(date.getUTCHours());
|
|
78
|
+
const mm = pad2(date.getUTCMinutes());
|
|
79
|
+
const ss = pad2(date.getUTCSeconds());
|
|
80
|
+
return `${hh}:${mm}:${ss}Z`;
|
|
78
81
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
const originalToLocaleString = Date.prototype.toLocaleString;
|
|
83
|
+
const originalToLocaleDateString = Date.prototype.toLocaleDateString;
|
|
84
|
+
const originalToLocaleTimeString = Date.prototype.toLocaleTimeString;
|
|
82
85
|
Date.prototype.toLocaleString = function toLocaleStringPatched(locale, options) {
|
|
83
86
|
if (!locale && !options) {
|
|
84
87
|
return formatAsISODateTime(this);
|
|
@@ -107,31 +110,22 @@ function runJestSetup() {
|
|
|
107
110
|
global.act = _react.act;
|
|
108
111
|
global.fireEvent = _react.fireEvent;
|
|
109
112
|
// Add MutationObserver polyfill for tests
|
|
110
|
-
global.MutationObserver =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
global.MutationObserver = class {
|
|
114
|
+
callback;
|
|
115
|
+
constructor(callback) {
|
|
113
116
|
this.callback = callback;
|
|
114
117
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
}, {
|
|
125
|
-
key: "takeRecords",
|
|
126
|
-
value: function takeRecords() {
|
|
127
|
-
return [];
|
|
128
|
-
}
|
|
129
|
-
}]);
|
|
130
|
-
}();
|
|
131
|
-
global.render = _react.render;
|
|
132
|
-
global.renderToJSON = function (component) {
|
|
133
|
-
return (0, _react.render)(component).container;
|
|
118
|
+
disconnect() {}
|
|
119
|
+
observe() {
|
|
120
|
+
// Call the callback immediately to simulate initial observation
|
|
121
|
+
this.callback([], this);
|
|
122
|
+
}
|
|
123
|
+
takeRecords() {
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
134
126
|
};
|
|
127
|
+
global.render = _react.render;
|
|
128
|
+
global.renderToJSON = component => (0, _react.render)(component).container;
|
|
135
129
|
global.screen = _react.screen;
|
|
136
130
|
expect.extend(_jestAxe.toHaveNoViolations);
|
|
137
131
|
expect.extend({
|
package/build/jest/utility.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.waitFor = exports.renderSnapshotAsync = exports.renderSnapshot = exports.createMockStore = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
7
|
/* eslint-disable testing-library/no-unnecessary-act */
|
|
11
8
|
/**
|
|
12
9
|
* Shared test utilities provided by @papillonarts/setup/jest.
|
|
@@ -31,9 +28,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
31
28
|
* ```
|
|
32
29
|
*/
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
return expect(global.renderToJSON(component)).toMatchSnapshot();
|
|
36
|
-
};
|
|
31
|
+
const renderSnapshot = component => expect(global.renderToJSON(component)).toMatchSnapshot();
|
|
37
32
|
|
|
38
33
|
/**
|
|
39
34
|
* Renders an async component and matches it against a snapshot.
|
|
@@ -52,45 +47,8 @@ var renderSnapshot = exports.renderSnapshot = function renderSnapshot(component)
|
|
|
52
47
|
* })
|
|
53
48
|
* ```
|
|
54
49
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var _t2;
|
|
58
|
-
return _regenerator["default"].wrap(function (_context2) {
|
|
59
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
60
|
-
case 0:
|
|
61
|
-
_t2 = expect;
|
|
62
|
-
_context2.next = 1;
|
|
63
|
-
return global.act(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
64
|
-
var _t;
|
|
65
|
-
return _regenerator["default"].wrap(function (_context) {
|
|
66
|
-
while (1) switch (_context.prev = _context.next) {
|
|
67
|
-
case 0:
|
|
68
|
-
_t = global;
|
|
69
|
-
_context.next = 1;
|
|
70
|
-
return component;
|
|
71
|
-
case 1:
|
|
72
|
-
return _context.abrupt("return", _t.renderToJSON.call(_t, _context.sent));
|
|
73
|
-
case 2:
|
|
74
|
-
case "end":
|
|
75
|
-
return _context.stop();
|
|
76
|
-
}
|
|
77
|
-
}, _callee);
|
|
78
|
-
})));
|
|
79
|
-
case 1:
|
|
80
|
-
_context2.next = 2;
|
|
81
|
-
return _t2(_context2.sent).toMatchSnapshot();
|
|
82
|
-
case 2:
|
|
83
|
-
return _context2.abrupt("return", _context2.sent);
|
|
84
|
-
case 3:
|
|
85
|
-
case "end":
|
|
86
|
-
return _context2.stop();
|
|
87
|
-
}
|
|
88
|
-
}, _callee2);
|
|
89
|
-
}));
|
|
90
|
-
return function renderSnapshotAsync(_x) {
|
|
91
|
-
return _ref.apply(this, arguments);
|
|
92
|
-
};
|
|
93
|
-
}();
|
|
50
|
+
exports.renderSnapshot = renderSnapshot;
|
|
51
|
+
const renderSnapshotAsync = async component => await expect(await global.act(async () => global.renderToJSON(await component))).toMatchSnapshot();
|
|
94
52
|
|
|
95
53
|
/**
|
|
96
54
|
* Creates a mock store with default configuration.
|
|
@@ -106,8 +64,8 @@ var renderSnapshotAsync = exports.renderSnapshotAsync = /*#__PURE__*/function ()
|
|
|
106
64
|
* const store = createMockStore({ context: { cars: [] } })
|
|
107
65
|
* ```
|
|
108
66
|
*/
|
|
109
|
-
|
|
110
|
-
|
|
67
|
+
exports.renderSnapshotAsync = renderSnapshotAsync;
|
|
68
|
+
const createMockStore = (initialState = {}) => {
|
|
111
69
|
// This is a placeholder - implement based on your store configuration
|
|
112
70
|
// You may need to import from redux-mock-store or similar
|
|
113
71
|
return initialState;
|
|
@@ -127,43 +85,14 @@ var createMockStore = exports.createMockStore = function createMockStore() {
|
|
|
127
85
|
* await waitFor(() => element.textContent === 'Loaded', 2000)
|
|
128
86
|
* ```
|
|
129
87
|
*/
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
startTime = Date.now();
|
|
142
|
-
case 1:
|
|
143
|
-
if (condition()) {
|
|
144
|
-
_context3.next = 4;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
if (!(Date.now() - startTime > timeout)) {
|
|
148
|
-
_context3.next = 2;
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
throw new Error("Timeout waiting for condition after ".concat(timeout, "ms"));
|
|
152
|
-
case 2:
|
|
153
|
-
_context3.next = 3;
|
|
154
|
-
return new Promise(function (resolve) {
|
|
155
|
-
return setTimeout(resolve, interval);
|
|
156
|
-
});
|
|
157
|
-
case 3:
|
|
158
|
-
_context3.next = 1;
|
|
159
|
-
break;
|
|
160
|
-
case 4:
|
|
161
|
-
case "end":
|
|
162
|
-
return _context3.stop();
|
|
163
|
-
}
|
|
164
|
-
}, _callee3);
|
|
165
|
-
}));
|
|
166
|
-
return function waitFor(_x2) {
|
|
167
|
-
return _ref3.apply(this, arguments);
|
|
168
|
-
};
|
|
169
|
-
}();
|
|
88
|
+
exports.createMockStore = createMockStore;
|
|
89
|
+
const waitFor = async (condition, timeout = 1000, interval = 50) => {
|
|
90
|
+
const startTime = Date.now();
|
|
91
|
+
while (!condition()) {
|
|
92
|
+
if (Date.now() - startTime > timeout) {
|
|
93
|
+
throw new Error(`Timeout waiting for condition after ${timeout}ms`);
|
|
94
|
+
}
|
|
95
|
+
await new Promise(resolve => setTimeout(resolve, interval));
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
exports.waitFor = waitFor;
|
package/build/storybook/index.js
CHANGED
|
@@ -5,19 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "getStorybookMainSetup", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _mainSetup.getStorybookMainSetup;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "getStorybookPreviewSetup", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function
|
|
14
|
+
get: function () {
|
|
15
15
|
return _previewSetup.getStorybookPreviewSetup;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "setStorybookManagerSetup", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function
|
|
20
|
+
get: function () {
|
|
21
21
|
return _managerSetup.setStorybookManagerSetup;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mainSetup.d.ts","sourceRoot":"","sources":["../../src/storybook/mainSetup.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAOhE,wBAAgB,qBAAqB,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE;;;;CAAA,
|
|
1
|
+
{"version":3,"file":"mainSetup.d.ts","sourceRoot":"","sources":["../../src/storybook/mainSetup.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAOhE,wBAAgB,qBAAqB,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE;;;;CAAA,mBAoQ1E"}
|