@rspack/test-tools 2.0.3 → 2.0.5

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/dist/case/hook.js CHANGED
@@ -39,7 +39,6 @@ __webpack_require__.d(__webpack_exports__, {
39
39
  const external_node_path_namespaceObject = require("node:path");
40
40
  var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
41
41
  const core_namespaceObject = require("@rspack/core");
42
- const external_jest_snapshot_namespaceObject = require("jest-snapshot");
43
42
  const external_path_serializer_namespaceObject = require("path-serializer");
44
43
  const external_pretty_format_namespaceObject = require("pretty-format");
45
44
  const external_rspack_merge_namespaceObject = require("rspack-merge");
@@ -47,6 +46,7 @@ var external_rspack_merge_default = /*#__PURE__*/ __webpack_require__.n(external
47
46
  const context_js_namespaceObject = require("../test/context.js");
48
47
  const creator_js_namespaceObject = require("../test/creator.js");
49
48
  const external_common_js_namespaceObject = require("./common.js");
49
+ const snapshot_serializers_js_namespaceObject = require("../helper/expect/snapshot-serializers.js");
50
50
  const srcDir = __TEST_FIXTURES_PATH__;
51
51
  const distDir = external_node_path_default().resolve(__TEST_DIST_PATH__, 'hook');
52
52
  const creator = new creator_js_namespaceObject.BasicCaseCreator({
@@ -131,7 +131,7 @@ const serialize = (val, indent = 2, formatOverrides = {})=>normalizeNewlines((0,
131
131
  escapeRegex,
132
132
  indent,
133
133
  plugins: [
134
- ...(0, external_jest_snapshot_namespaceObject.getSerializers)(),
134
+ ...(0, snapshot_serializers_js_namespaceObject.getSnapshotSerializers)(),
135
135
  sourceSerializer,
136
136
  internalSerializer,
137
137
  testPathSerializer
@@ -0,0 +1,4 @@
1
+ import { type Plugins } from 'pretty-format';
2
+ export declare const getSnapshotSerializers: () => Plugins;
3
+ export declare const normalizeNewlines: (str: string) => string;
4
+ export declare const serializeSnapshot: (val: unknown, indent?: number, formatOverrides?: {}) => string;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ getSnapshotSerializers: ()=>getSnapshotSerializers,
28
+ normalizeNewlines: ()=>normalizeNewlines,
29
+ serializeSnapshot: ()=>serializeSnapshot
30
+ });
31
+ const external_pretty_format_namespaceObject = require("pretty-format");
32
+ const { AsymmetricMatcher, DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent } = external_pretty_format_namespaceObject.plugins;
33
+ const mockSerializer = {
34
+ test (val) {
35
+ return Boolean(val && 'object' == typeof val && val._isMockFunction);
36
+ },
37
+ serialize (val, config, indentation, depth, refs, printer) {
38
+ const name = val.getMockName();
39
+ const nameString = 'jest.fn()' === name ? '' : ` ${name}`;
40
+ let callsString = '';
41
+ if (0 !== val.mock.calls.length) {
42
+ const indentationNext = indentation + config.indent;
43
+ callsString = ` {${config.spacingOuter}${indentationNext}"calls": ${printer(val.mock.calls, config, indentationNext, depth, refs)}${config.min ? ', ' : ','}${config.spacingOuter}${indentationNext}"results": ${printer(val.mock.results, config, indentationNext, depth, refs)}${config.min ? '' : ','}${config.spacingOuter}${indentation}}`;
44
+ }
45
+ return `[MockFunction${nameString}]${callsString}`;
46
+ }
47
+ };
48
+ const getSnapshotSerializers = ()=>[
49
+ ReactTestComponent,
50
+ ReactElement,
51
+ DOMElement,
52
+ DOMCollection,
53
+ Immutable,
54
+ mockSerializer,
55
+ AsymmetricMatcher
56
+ ];
57
+ const normalizeNewlines = (str)=>str.replace(/\r\n|\r/g, '\n');
58
+ const serializeSnapshot = (val, indent = 2, formatOverrides = {})=>normalizeNewlines((0, external_pretty_format_namespaceObject.format)(val, {
59
+ escapeRegex: true,
60
+ indent,
61
+ plugins: getSnapshotSerializers(),
62
+ printFunctionName: false,
63
+ ...formatOverrides
64
+ }));
65
+ exports.getSnapshotSerializers = __webpack_exports__.getSnapshotSerializers;
66
+ exports.normalizeNewlines = __webpack_exports__.normalizeNewlines;
67
+ exports.serializeSnapshot = __webpack_exports__.serializeSnapshot;
68
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
69
+ "getSnapshotSerializers",
70
+ "normalizeNewlines",
71
+ "serializeSnapshot"
72
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
73
+ Object.defineProperty(exports, '__esModule', {
74
+ value: true
75
+ });
@@ -45,13 +45,12 @@ const external_filenamify_namespaceObject = require("filenamify");
45
45
  var external_filenamify_default = /*#__PURE__*/ __webpack_require__.n(external_filenamify_namespaceObject);
46
46
  const external_jest_diff_namespaceObject = require("jest-diff");
47
47
  const external_serializers_js_namespaceObject = require("../serializers.js");
48
- const { serialize } = require(external_node_path_default().join(external_node_path_default().dirname(require.resolve('jest-snapshot')), './utils.js'));
49
- const { getSerializers } = require(external_node_path_default().join(external_node_path_default().dirname(require.resolve('jest-snapshot')), './plugins.js'));
48
+ const external_snapshot_serializers_js_namespaceObject = require("./snapshot-serializers.js");
50
49
  const isEqual = (a, b)=>Buffer.isBuffer(a) ? a.equals(b) : a === b;
51
50
  function toMatchFileSnapshotSync(rawContent, filepath, options = {}) {
52
- const content = Buffer.isBuffer(rawContent) ? rawContent : serialize(rawContent, 2, {
51
+ const content = Buffer.isBuffer(rawContent) ? rawContent : (0, external_snapshot_serializers_js_namespaceObject.serializeSnapshot)(rawContent, 2, {
53
52
  plugins: [
54
- ...getSerializers(),
53
+ ...(0, external_snapshot_serializers_js_namespaceObject.getSnapshotSerializers)(),
55
54
  ...external_serializers_js_namespaceObject.serializers
56
55
  ]
57
56
  });
@@ -148,14 +148,18 @@ class HotUpdatePlugin {
148
148
  });
149
149
  compilation.hooks.runtimeModule.tap(PLUGIN_NAME, (module, _set)=>{
150
150
  if ('DefinePropertyGettersRuntimeModule' === module.constructor.name) module.source.source = Buffer.from(`
151
- ${RuntimeGlobals.definePropertyGetters} = function (exports, definition) {
152
- for (var key in definition) {
153
- if (${RuntimeGlobals.hasOwnProperty}(definition, key) && !${RuntimeGlobals.hasOwnProperty}(exports, key)) {
154
- Object.defineProperty(exports, key, { configurable: true, enumerable: true, get: definition[key] });
155
- }
156
- }
157
- };
158
- `, 'utf-8');
151
+ ${RuntimeGlobals.definePropertyGetters} = function (exports, getters, values) {
152
+ var define = function (defs, kind) {
153
+ for(var key in defs) {
154
+ if(${RuntimeGlobals.hasOwnProperty}(defs, key) && !${RuntimeGlobals.hasOwnProperty}(exports, key)) {
155
+ Object.defineProperty(exports, key, { configurable: true, enumerable: true, [kind]: defs[key] });
156
+ }
157
+ }
158
+ }
159
+ define(getters, "get");
160
+ define(values, "value");
161
+ };
162
+ `, 'utf-8');
159
163
  });
160
164
  });
161
165
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/test-tools",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "Test tools for rspack",
5
5
  "homepage": "https://rspack.rs",
6
6
  "bugs": "https://github.com/web-infra-dev/rspack/issues",
@@ -44,7 +44,6 @@
44
44
  "iconv-lite": "^0.7.2",
45
45
  "javascript-stringify": "^2.1.0",
46
46
  "jest-diff": "^30.3.0",
47
- "jest-snapshot": "29.7.0",
48
47
  "jsdom": "^26.1.0",
49
48
  "memfs": "4.57.2",
50
49
  "path-serializer": "0.6.0",
@@ -54,17 +53,16 @@
54
53
  "source-map": "^0.7.6",
55
54
  "terser-webpack-plugin": "^5.5.0",
56
55
  "wast-loader": "^1.14.1",
57
- "webpack": "5.104.1",
58
56
  "webpack-sources": "3.3.4"
59
57
  },
60
58
  "devDependencies": {
61
- "@rslib/core": "^0.21.4",
59
+ "@rslib/core": "^0.21.5",
62
60
  "@types/babel__generator": "7.27.0",
63
61
  "@types/babel__traverse": "7.28.0",
64
62
  "@types/fs-extra": "11.0.4",
65
63
  "@types/jsdom": "^21.1.7",
66
64
  "typescript": "^6.0.3",
67
- "@rspack/core": "2.0.3"
65
+ "@rspack/core": "2.0.5"
68
66
  },
69
67
  "peerDependencies": {
70
68
  "@rspack/core": ">=1.0.0"