@wordpress/jest-console 8.32.0 → 8.32.1-next.ff1cebbba.0

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.
@@ -1,2 +1,2 @@
1
1
  "use strict";
2
- //# sourceMappingURL=declarations.d.js.map
2
+ //# sourceMappingURL=declarations.d.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/jest-console/src/declarations.d.ts"],"sourcesContent":["// Definitions originally written by Damien Sorel <https://github.com/mistic100> under MIT license.\n// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/f0b72c12f6b561e4342dc8a1cf87432d2ad40ae7/types/wordpress__jest-console/index.d.ts\n\ndeclare namespace jest {\n\tinterface Matchers< R, T > {\n\t\t/**\n\t\t * Ensure that `console.error` function was called.\n\t\t */\n\t\ttoHaveErrored(): R;\n\n\t\t/**\n\t\t * Ensure that `console.error` function was called with specific arguments.\n\t\t */\n\t\ttoHaveErroredWith( ...args: unknown[] ): R;\n\n\t\t/**\n\t\t * Ensure that `console.info` function was called.\n\t\t */\n\t\ttoHaveInformed(): R;\n\n\t\t/**\n\t\t * Ensure that `console.info` function was called with specific arguments.\n\t\t */\n\t\ttoHaveInformedWith( ...args: unknown[] ): R;\n\n\t\t/**\n\t\t * Ensure that `console.log` function was called.\n\t\t */\n\t\ttoHaveLogged(): R;\n\n\t\t/**\n\t\t * Ensure that `console.log` function was called with specific arguments.\n\t\t */\n\t\ttoHaveLoggedWith( ...args: unknown[] ): R;\n\n\t\t/**\n\t\t * Ensure that `console.warn` function was called.\n\t\t */\n\t\ttoHaveWarned(): R;\n\n\t\t/**\n\t\t * Ensure that `console.warn` function was called with specific arguments.\n\t\t */\n\t\ttoHaveWarnedWith( ...args: unknown[] ): R;\n\t}\n}\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
package/build/index.js CHANGED
@@ -1,32 +1,35 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- require("./matchers");
5
- var _supportedMatchers = _interopRequireDefault(require("./supported-matchers"));
6
- /**
7
- * Internal dependencies
8
- */
9
-
10
- /**
11
- * Sets spy on the console object's method to make it possible to fail test when method called without assertion.
12
- *
13
- * @param args
14
- */
15
- const setConsoleMethodSpy = args => {
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var import_matchers = require("./matchers");
25
+ var import_supported_matchers = __toESM(require("./supported-matchers"));
26
+ const setConsoleMethodSpy = (args) => {
16
27
  const [methodName, matcherName] = args;
17
28
  const spy = jest.spyOn(console, methodName).mockName(`console.${methodName}`);
18
-
19
- /**
20
- * Resets the spy to its initial state.
21
- */
22
29
  function resetSpy() {
23
30
  spy.mockReset();
24
31
  spy.assertionsNumber = 0;
25
32
  }
26
-
27
- /**
28
- * Verifies that the spy has only been called if expected.
29
- */
30
33
  function assertExpectedCalls() {
31
34
  if (spy.assertionsNumber === 0 && spy.mock.calls.length > 0) {
32
35
  expect(console).not[matcherName]();
@@ -39,5 +42,5 @@ const setConsoleMethodSpy = args => {
39
42
  });
40
43
  afterEach(assertExpectedCalls);
41
44
  };
42
- Object.entries(_supportedMatchers.default).forEach(setConsoleMethodSpy);
43
- //# sourceMappingURL=index.js.map
45
+ Object.entries(import_supported_matchers.default).forEach(setConsoleMethodSpy);
46
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["require","_supportedMatchers","_interopRequireDefault","setConsoleMethodSpy","args","methodName","matcherName","spy","jest","spyOn","console","mockName","resetSpy","mockReset","assertionsNumber","assertExpectedCalls","mock","calls","length","expect","not","beforeAll","beforeEach","afterEach","Object","entries","supportedMatchers","forEach"],"sources":["@wordpress/jest-console/src/index.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport './matchers';\nimport supportedMatchers from './supported-matchers';\nimport type { ExtendedMock } from './types';\n\n/**\n * Sets spy on the console object's method to make it possible to fail test when method called without assertion.\n *\n * @param args\n */\nconst setConsoleMethodSpy = ( args: [ string, string ] ) => {\n\tconst [ methodName, matcherName ] = args;\n\tconst spy = jest\n\t\t.spyOn( console, methodName as 'error' | 'info' | 'log' | 'warn' )\n\t\t.mockName( `console.${ methodName }` ) as ExtendedMock;\n\n\t/**\n\t * Resets the spy to its initial state.\n\t */\n\tfunction resetSpy() {\n\t\tspy.mockReset();\n\t\tspy.assertionsNumber = 0;\n\t}\n\n\t/**\n\t * Verifies that the spy has only been called if expected.\n\t */\n\tfunction assertExpectedCalls() {\n\t\tif ( spy.assertionsNumber === 0 && spy.mock.calls.length > 0 ) {\n\t\t\texpect( console ).not[ matcherName ]();\n\t\t}\n\t}\n\n\tbeforeAll( resetSpy );\n\n\tbeforeEach( () => {\n\t\tassertExpectedCalls();\n\t\tresetSpy();\n\t} );\n\n\tafterEach( assertExpectedCalls );\n};\n\nObject.entries( supportedMatchers ).forEach( setConsoleMethodSpy );\n"],"mappings":";;;AAGAA,OAAA;AACA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAJA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA,MAAMG,mBAAmB,GAAKC,IAAwB,IAAM;EAC3D,MAAM,CAAEC,UAAU,EAAEC,WAAW,CAAE,GAAGF,IAAI;EACxC,MAAMG,GAAG,GAAGC,IAAI,CACdC,KAAK,CAAEC,OAAO,EAAEL,UAAgD,CAAC,CACjEM,QAAQ,CAAE,WAAYN,UAAU,EAAI,CAAiB;;EAEvD;AACD;AACA;EACC,SAASO,QAAQA,CAAA,EAAG;IACnBL,GAAG,CAACM,SAAS,CAAC,CAAC;IACfN,GAAG,CAACO,gBAAgB,GAAG,CAAC;EACzB;;EAEA;AACD;AACA;EACC,SAASC,mBAAmBA,CAAA,EAAG;IAC9B,IAAKR,GAAG,CAACO,gBAAgB,KAAK,CAAC,IAAIP,GAAG,CAACS,IAAI,CAACC,KAAK,CAACC,MAAM,GAAG,CAAC,EAAG;MAC9DC,MAAM,CAAET,OAAQ,CAAC,CAACU,GAAG,CAAEd,WAAW,CAAE,CAAC,CAAC;IACvC;EACD;EAEAe,SAAS,CAAET,QAAS,CAAC;EAErBU,UAAU,CAAE,MAAM;IACjBP,mBAAmB,CAAC,CAAC;IACrBH,QAAQ,CAAC,CAAC;EACX,CAAE,CAAC;EAEHW,SAAS,CAAER,mBAAoB,CAAC;AACjC,CAAC;AAEDS,MAAM,CAACC,OAAO,CAAEC,0BAAkB,CAAC,CAACC,OAAO,CAAExB,mBAAoB,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport './matchers';\nimport supportedMatchers from './supported-matchers';\nimport type { ExtendedMock } from './types';\n\n/**\n * Sets spy on the console object's method to make it possible to fail test when method called without assertion.\n *\n * @param args\n */\nconst setConsoleMethodSpy = ( args: [ string, string ] ) => {\n\tconst [ methodName, matcherName ] = args;\n\tconst spy = jest\n\t\t.spyOn( console, methodName as 'error' | 'info' | 'log' | 'warn' )\n\t\t.mockName( `console.${ methodName }` ) as ExtendedMock;\n\n\t/**\n\t * Resets the spy to its initial state.\n\t */\n\tfunction resetSpy() {\n\t\tspy.mockReset();\n\t\tspy.assertionsNumber = 0;\n\t}\n\n\t/**\n\t * Verifies that the spy has only been called if expected.\n\t */\n\tfunction assertExpectedCalls() {\n\t\tif ( spy.assertionsNumber === 0 && spy.mock.calls.length > 0 ) {\n\t\t\texpect( console ).not[ matcherName ]();\n\t\t}\n\t}\n\n\tbeforeAll( resetSpy );\n\n\tbeforeEach( () => {\n\t\tassertExpectedCalls();\n\t\tresetSpy();\n\t} );\n\n\tafterEach( assertExpectedCalls );\n};\n\nObject.entries( supportedMatchers ).forEach( setConsoleMethodSpy );\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAGA,sBAAO;AACP,gCAA8B;AAQ9B,MAAM,sBAAsB,CAAE,SAA8B;AAC3D,QAAM,CAAE,YAAY,WAAY,IAAI;AACpC,QAAM,MAAM,KACV,MAAO,SAAS,UAAgD,EAChE,SAAU,WAAY,UAAW,EAAG;AAKtC,WAAS,WAAW;AACnB,QAAI,UAAU;AACd,QAAI,mBAAmB;AAAA,EACxB;AAKA,WAAS,sBAAsB;AAC9B,QAAK,IAAI,qBAAqB,KAAK,IAAI,KAAK,MAAM,SAAS,GAAI;AAC9D,aAAQ,OAAQ,EAAE,IAAK,WAAY,EAAE;AAAA,IACtC;AAAA,EACD;AAEA,YAAW,QAAS;AAEpB,aAAY,MAAM;AACjB,wBAAoB;AACpB,aAAS;AAAA,EACV,CAAE;AAEF,YAAW,mBAAoB;AAChC;AAEA,OAAO,QAAS,0BAAAA,OAAkB,EAAE,QAAS,mBAAoB;",
6
+ "names": ["supportedMatchers"]
7
+ }
package/build/matchers.js CHANGED
@@ -1,28 +1,45 @@
1
1
  "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var import_jest_matcher_utils = require("jest-matcher-utils");
25
+ var import_supported_matchers = __toESM(require("./supported-matchers"));
26
+ const createErrorMessage = (spyInfo) => {
27
+ const { spy, pass, calls, matcherName, methodName, expected } = spyInfo;
28
+ const hint = pass ? `.not${matcherName}` : matcherName;
29
+ const message = pass ? `Expected mock function not to be called but it was called with:
30
+ ${calls.map(
31
+ import_jest_matcher_utils.printReceived
32
+ )}` : `Expected mock function to be called${expected ? ` with:
33
+ ${(0, import_jest_matcher_utils.printExpected)(expected)}
34
+ ` : "."}
35
+ but it was called with:
36
+ ${calls.map(import_jest_matcher_utils.printReceived)}`;
37
+ return () => `${(0, import_jest_matcher_utils.matcherHint)(hint, spy.getMockName())}
2
38
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _jestMatcherUtils = require("jest-matcher-utils");
5
- var _supportedMatchers = _interopRequireDefault(require("./supported-matchers"));
6
- /**
7
- * External dependencies
8
- */
9
-
10
- /**
11
- * Internal dependencies
12
- */
39
+ ` + message + `
13
40
 
14
- const createErrorMessage = spyInfo => {
15
- const {
16
- spy,
17
- pass,
18
- calls,
19
- matcherName,
20
- methodName,
21
- expected
22
- } = spyInfo;
23
- const hint = pass ? `.not${matcherName}` : matcherName;
24
- const message = pass ? `Expected mock function not to be called but it was called with:\n${calls.map(_jestMatcherUtils.printReceived)}` : `Expected mock function to be called${expected ? ` with:\n${(0, _jestMatcherUtils.printExpected)(expected)}\n` : '.'}\nbut it was called with:\n${calls.map(_jestMatcherUtils.printReceived)}`;
25
- return () => `${(0, _jestMatcherUtils.matcherHint)(hint, spy.getMockName())}` + '\n\n' + message + '\n\n' + `console.${methodName}() should not be used unless explicitly expected\n` + 'See https://www.npmjs.com/package/@wordpress/jest-console for details.';
41
+ console.${methodName}() should not be used unless explicitly expected
42
+ See https://www.npmjs.com/package/@wordpress/jest-console for details.`;
26
43
  };
27
44
  const createSpyInfo = (spy, matcherName, methodName, expected) => {
28
45
  const calls = spy.mock.calls;
@@ -40,24 +57,35 @@ const createSpyInfo = (spy, matcherName, methodName, expected) => {
40
57
  message
41
58
  };
42
59
  };
43
- const createToHaveBeenCalledMatcher = (matcherName, methodName) => received => {
60
+ const createToHaveBeenCalledMatcher = (matcherName, methodName) => (received) => {
44
61
  const spy = received[methodName];
45
62
  const spyInfo = createSpyInfo(spy, matcherName, methodName);
46
63
  spy.assertionsNumber += 1;
47
64
  return spyInfo;
48
65
  };
49
- const createToHaveBeenCalledWith = (matcherName, methodName) => function (received, ...expected) {
66
+ const createToHaveBeenCalledWith = (matcherName, methodName) => function(received, ...expected) {
50
67
  const spy = received[methodName];
51
68
  const spyInfo = createSpyInfo(spy, matcherName, methodName, expected);
52
69
  spy.assertionsNumber += 1;
53
70
  return spyInfo;
54
71
  };
55
- expect.extend(Object.entries(_supportedMatchers.default).reduce((result, [methodName, matcherName]) => {
56
- const matcherNameWith = `${matcherName}With`;
57
- return {
58
- ...result,
59
- [matcherName]: createToHaveBeenCalledMatcher(`.${matcherName}`, methodName),
60
- [matcherNameWith]: createToHaveBeenCalledWith(`.${matcherNameWith}`, methodName)
61
- };
62
- }, {}));
63
- //# sourceMappingURL=matchers.js.map
72
+ expect.extend(
73
+ Object.entries(import_supported_matchers.default).reduce(
74
+ (result, [methodName, matcherName]) => {
75
+ const matcherNameWith = `${matcherName}With`;
76
+ return {
77
+ ...result,
78
+ [matcherName]: createToHaveBeenCalledMatcher(
79
+ `.${matcherName}`,
80
+ methodName
81
+ ),
82
+ [matcherNameWith]: createToHaveBeenCalledWith(
83
+ `.${matcherNameWith}`,
84
+ methodName
85
+ )
86
+ };
87
+ },
88
+ {}
89
+ )
90
+ );
91
+ //# sourceMappingURL=matchers.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_jestMatcherUtils","require","_supportedMatchers","_interopRequireDefault","createErrorMessage","spyInfo","spy","pass","calls","matcherName","methodName","expected","hint","message","map","printReceived","printExpected","matcherHint","getMockName","createSpyInfo","mock","JSON","stringify","includes","length","createToHaveBeenCalledMatcher","received","assertionsNumber","createToHaveBeenCalledWith","expect","extend","Object","entries","supportedMatchers","reduce","result","matcherNameWith"],"sources":["@wordpress/jest-console/src/matchers.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport { matcherHint, printExpected, printReceived } from 'jest-matcher-utils';\n\n/**\n * Internal dependencies\n */\nimport supportedMatchers from './supported-matchers';\nimport type { Mock } from 'jest-mock';\nimport type {\n\tExtendedMock,\n\tMatcherFunction,\n\tMatcherResult,\n\tMatcherWithArgsFunction,\n} from './types';\n\ninterface SpyInfo {\n\tspy: Mock;\n\tpass: boolean;\n\tcalls: unknown[][];\n\tmatcherName: string;\n\tmethodName: string;\n\texpected?: unknown[];\n}\n\nconst createErrorMessage = ( spyInfo: SpyInfo ) => {\n\tconst { spy, pass, calls, matcherName, methodName, expected } = spyInfo;\n\tconst hint = pass ? `.not${ matcherName }` : matcherName;\n\tconst message = pass\n\t\t? `Expected mock function not to be called but it was called with:\\n${ calls.map(\n\t\t\t\tprintReceived\n\t\t ) }`\n\t\t: `Expected mock function to be called${\n\t\t\t\texpected ? ` with:\\n${ printExpected( expected ) }\\n` : '.'\n\t\t }\\nbut it was called with:\\n${ calls.map( printReceived ) }`;\n\n\treturn () =>\n\t\t`${ matcherHint( hint, spy.getMockName() ) }` +\n\t\t'\\n\\n' +\n\t\tmessage +\n\t\t'\\n\\n' +\n\t\t`console.${ methodName }() should not be used unless explicitly expected\\n` +\n\t\t'See https://www.npmjs.com/package/@wordpress/jest-console for details.';\n};\n\nconst createSpyInfo = (\n\tspy: Mock,\n\tmatcherName: string,\n\tmethodName: string,\n\texpected?: unknown[]\n) => {\n\tconst calls = spy.mock.calls;\n\n\tconst pass = expected\n\t\t? JSON.stringify( calls ).includes( JSON.stringify( expected ) )\n\t\t: calls.length > 0;\n\n\tconst message = createErrorMessage( {\n\t\tspy,\n\t\tpass,\n\t\tcalls,\n\t\tmatcherName,\n\t\tmethodName,\n\t\texpected,\n\t} );\n\n\treturn {\n\t\tpass,\n\t\tmessage,\n\t};\n};\n\nconst createToHaveBeenCalledMatcher =\n\t( matcherName: string, methodName: string ) =>\n\t( received: Record< string, Mock > ): MatcherResult => {\n\t\tconst spy = received[ methodName ] as ExtendedMock;\n\t\tconst spyInfo = createSpyInfo( spy, matcherName, methodName );\n\t\tspy.assertionsNumber += 1;\n\t\treturn spyInfo;\n\t};\n\nconst createToHaveBeenCalledWith = (\n\tmatcherName: string,\n\tmethodName: string\n) =>\n\tfunction (\n\t\treceived: Record< string, Mock >,\n\t\t...expected: unknown[]\n\t): MatcherResult {\n\t\tconst spy = received[ methodName ] as ExtendedMock;\n\t\tconst spyInfo = createSpyInfo( spy, matcherName, methodName, expected );\n\t\tspy.assertionsNumber += 1;\n\t\treturn spyInfo;\n\t};\n\ntype MatchersObject = Record<\n\tstring,\n\tMatcherFunction | MatcherWithArgsFunction\n>;\n\nexpect.extend(\n\tObject.entries( supportedMatchers ).reduce< MatchersObject >(\n\t\t( result, [ methodName, matcherName ] ) => {\n\t\t\tconst matcherNameWith = `${ matcherName }With`;\n\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\t[ matcherName ]: createToHaveBeenCalledMatcher(\n\t\t\t\t\t`.${ matcherName }`,\n\t\t\t\t\tmethodName\n\t\t\t\t),\n\t\t\t\t[ matcherNameWith ]: createToHaveBeenCalledWith(\n\t\t\t\t\t`.${ matcherNameWith }`,\n\t\t\t\t\tmethodName\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t{}\n\t)\n);\n"],"mappings":";;;AAGA,IAAAA,iBAAA,GAAAC,OAAA;AAKA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAmBA,MAAMG,kBAAkB,GAAKC,OAAgB,IAAM;EAClD,MAAM;IAAEC,GAAG;IAAEC,IAAI;IAAEC,KAAK;IAAEC,WAAW;IAAEC,UAAU;IAAEC;EAAS,CAAC,GAAGN,OAAO;EACvE,MAAMO,IAAI,GAAGL,IAAI,GAAG,OAAQE,WAAW,EAAG,GAAGA,WAAW;EACxD,MAAMI,OAAO,GAAGN,IAAI,GACjB,oEAAqEC,KAAK,CAACM,GAAG,CAC9EC,+BACA,CAAC,EAAG,GACJ,sCACAJ,QAAQ,GAAG,WAAY,IAAAK,+BAAa,EAAEL,QAAS,CAAC,IAAK,GAAG,GAAG,8BAC5BH,KAAK,CAACM,GAAG,CAAEC,+BAAc,CAAC,EAAG;EAE/D,OAAO,MACN,GAAI,IAAAE,6BAAW,EAAEL,IAAI,EAAEN,GAAG,CAACY,WAAW,CAAC,CAAE,CAAC,EAAG,GAC7C,MAAM,GACNL,OAAO,GACP,MAAM,GACN,WAAYH,UAAU,oDAAqD,GAC3E,wEAAwE;AAC1E,CAAC;AAED,MAAMS,aAAa,GAAGA,CACrBb,GAAS,EACTG,WAAmB,EACnBC,UAAkB,EAClBC,QAAoB,KAChB;EACJ,MAAMH,KAAK,GAAGF,GAAG,CAACc,IAAI,CAACZ,KAAK;EAE5B,MAAMD,IAAI,GAAGI,QAAQ,GAClBU,IAAI,CAACC,SAAS,CAAEd,KAAM,CAAC,CAACe,QAAQ,CAAEF,IAAI,CAACC,SAAS,CAAEX,QAAS,CAAE,CAAC,GAC9DH,KAAK,CAACgB,MAAM,GAAG,CAAC;EAEnB,MAAMX,OAAO,GAAGT,kBAAkB,CAAE;IACnCE,GAAG;IACHC,IAAI;IACJC,KAAK;IACLC,WAAW;IACXC,UAAU;IACVC;EACD,CAAE,CAAC;EAEH,OAAO;IACNJ,IAAI;IACJM;EACD,CAAC;AACF,CAAC;AAED,MAAMY,6BAA6B,GAClCA,CAAEhB,WAAmB,EAAEC,UAAkB,KACvCgB,QAAgC,IAAqB;EACtD,MAAMpB,GAAG,GAAGoB,QAAQ,CAAEhB,UAAU,CAAkB;EAClD,MAAML,OAAO,GAAGc,aAAa,CAAEb,GAAG,EAAEG,WAAW,EAAEC,UAAW,CAAC;EAC7DJ,GAAG,CAACqB,gBAAgB,IAAI,CAAC;EACzB,OAAOtB,OAAO;AACf,CAAC;AAEF,MAAMuB,0BAA0B,GAAGA,CAClCnB,WAAmB,EACnBC,UAAkB,KAElB,UACCgB,QAAgC,EAChC,GAAGf,QAAmB,EACN;EAChB,MAAML,GAAG,GAAGoB,QAAQ,CAAEhB,UAAU,CAAkB;EAClD,MAAML,OAAO,GAAGc,aAAa,CAAEb,GAAG,EAAEG,WAAW,EAAEC,UAAU,EAAEC,QAAS,CAAC;EACvEL,GAAG,CAACqB,gBAAgB,IAAI,CAAC;EACzB,OAAOtB,OAAO;AACf,CAAC;AAOFwB,MAAM,CAACC,MAAM,CACZC,MAAM,CAACC,OAAO,CAAEC,0BAAkB,CAAC,CAACC,MAAM,CACzC,CAAEC,MAAM,EAAE,CAAEzB,UAAU,EAAED,WAAW,CAAE,KAAM;EAC1C,MAAM2B,eAAe,GAAG,GAAI3B,WAAW,MAAO;EAE9C,OAAO;IACN,GAAG0B,MAAM;IACT,CAAE1B,WAAW,GAAIgB,6BAA6B,CAC7C,IAAKhB,WAAW,EAAG,EACnBC,UACD,CAAC;IACD,CAAE0B,eAAe,GAAIR,0BAA0B,CAC9C,IAAKQ,eAAe,EAAG,EACvB1B,UACD;EACD,CAAC;AACF,CAAC,EACD,CAAC,CACF,CACD,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/matchers.ts"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { matcherHint, printExpected, printReceived } from 'jest-matcher-utils';\n\n/**\n * Internal dependencies\n */\nimport supportedMatchers from './supported-matchers';\nimport type { Mock } from 'jest-mock';\nimport type {\n\tExtendedMock,\n\tMatcherFunction,\n\tMatcherResult,\n\tMatcherWithArgsFunction,\n} from './types';\n\ninterface SpyInfo {\n\tspy: Mock;\n\tpass: boolean;\n\tcalls: unknown[][];\n\tmatcherName: string;\n\tmethodName: string;\n\texpected?: unknown[];\n}\n\nconst createErrorMessage = ( spyInfo: SpyInfo ) => {\n\tconst { spy, pass, calls, matcherName, methodName, expected } = spyInfo;\n\tconst hint = pass ? `.not${ matcherName }` : matcherName;\n\tconst message = pass\n\t\t? `Expected mock function not to be called but it was called with:\\n${ calls.map(\n\t\t\t\tprintReceived\n\t\t ) }`\n\t\t: `Expected mock function to be called${\n\t\t\t\texpected ? ` with:\\n${ printExpected( expected ) }\\n` : '.'\n\t\t }\\nbut it was called with:\\n${ calls.map( printReceived ) }`;\n\n\treturn () =>\n\t\t`${ matcherHint( hint, spy.getMockName() ) }` +\n\t\t'\\n\\n' +\n\t\tmessage +\n\t\t'\\n\\n' +\n\t\t`console.${ methodName }() should not be used unless explicitly expected\\n` +\n\t\t'See https://www.npmjs.com/package/@wordpress/jest-console for details.';\n};\n\nconst createSpyInfo = (\n\tspy: Mock,\n\tmatcherName: string,\n\tmethodName: string,\n\texpected?: unknown[]\n) => {\n\tconst calls = spy.mock.calls;\n\n\tconst pass = expected\n\t\t? JSON.stringify( calls ).includes( JSON.stringify( expected ) )\n\t\t: calls.length > 0;\n\n\tconst message = createErrorMessage( {\n\t\tspy,\n\t\tpass,\n\t\tcalls,\n\t\tmatcherName,\n\t\tmethodName,\n\t\texpected,\n\t} );\n\n\treturn {\n\t\tpass,\n\t\tmessage,\n\t};\n};\n\nconst createToHaveBeenCalledMatcher =\n\t( matcherName: string, methodName: string ) =>\n\t( received: Record< string, Mock > ): MatcherResult => {\n\t\tconst spy = received[ methodName ] as ExtendedMock;\n\t\tconst spyInfo = createSpyInfo( spy, matcherName, methodName );\n\t\tspy.assertionsNumber += 1;\n\t\treturn spyInfo;\n\t};\n\nconst createToHaveBeenCalledWith = (\n\tmatcherName: string,\n\tmethodName: string\n) =>\n\tfunction (\n\t\treceived: Record< string, Mock >,\n\t\t...expected: unknown[]\n\t): MatcherResult {\n\t\tconst spy = received[ methodName ] as ExtendedMock;\n\t\tconst spyInfo = createSpyInfo( spy, matcherName, methodName, expected );\n\t\tspy.assertionsNumber += 1;\n\t\treturn spyInfo;\n\t};\n\ntype MatchersObject = Record<\n\tstring,\n\tMatcherFunction | MatcherWithArgsFunction\n>;\n\nexpect.extend(\n\tObject.entries( supportedMatchers ).reduce< MatchersObject >(\n\t\t( result, [ methodName, matcherName ] ) => {\n\t\t\tconst matcherNameWith = `${ matcherName }With`;\n\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\t[ matcherName ]: createToHaveBeenCalledMatcher(\n\t\t\t\t\t`.${ matcherName }`,\n\t\t\t\t\tmethodName\n\t\t\t\t),\n\t\t\t\t[ matcherNameWith ]: createToHaveBeenCalledWith(\n\t\t\t\t\t`.${ matcherNameWith }`,\n\t\t\t\t\tmethodName\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t{}\n\t)\n);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAGA,gCAA0D;AAK1D,gCAA8B;AAkB9B,MAAM,qBAAqB,CAAE,YAAsB;AAClD,QAAM,EAAE,KAAK,MAAM,OAAO,aAAa,YAAY,SAAS,IAAI;AAChE,QAAM,OAAO,OAAO,OAAQ,WAAY,KAAK;AAC7C,QAAM,UAAU,OACb;AAAA,EAAqE,MAAM;AAAA,IAC3E;AAAA,EACA,CAAE,KACF,sCACA,WAAW;AAAA,MAAY,yCAAe,QAAS,CAAE;AAAA,IAAO,GACxD;AAAA;AAAA,EAA+B,MAAM,IAAK,uCAAc,CAAE;AAE7D,SAAO,MACN,OAAI,uCAAa,MAAM,IAAI,YAAY,CAAE,CAAE;AAAA;AAAA,IAE3C,UACA;AAAA;AAAA,UACY,UAAW;AAAA;AAEzB;AAEA,MAAM,gBAAgB,CACrB,KACA,aACA,YACA,aACI;AACJ,QAAM,QAAQ,IAAI,KAAK;AAEvB,QAAM,OAAO,WACV,KAAK,UAAW,KAAM,EAAE,SAAU,KAAK,UAAW,QAAS,CAAE,IAC7D,MAAM,SAAS;AAElB,QAAM,UAAU,mBAAoB;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SAAO;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAEA,MAAM,gCACL,CAAE,aAAqB,eACvB,CAAE,aAAqD;AACtD,QAAM,MAAM,SAAU,UAAW;AACjC,QAAM,UAAU,cAAe,KAAK,aAAa,UAAW;AAC5D,MAAI,oBAAoB;AACxB,SAAO;AACR;AAED,MAAM,6BAA6B,CAClC,aACA,eAEA,SACC,aACG,UACa;AAChB,QAAM,MAAM,SAAU,UAAW;AACjC,QAAM,UAAU,cAAe,KAAK,aAAa,YAAY,QAAS;AACtE,MAAI,oBAAoB;AACxB,SAAO;AACR;AAOD,OAAO;AAAA,EACN,OAAO,QAAS,0BAAAA,OAAkB,EAAE;AAAA,IACnC,CAAE,QAAQ,CAAE,YAAY,WAAY,MAAO;AAC1C,YAAM,kBAAkB,GAAI,WAAY;AAExC,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,WAAY,GAAG;AAAA,UAChB,IAAK,WAAY;AAAA,UACjB;AAAA,QACD;AAAA,QACA,CAAE,eAAgB,GAAG;AAAA,UACpB,IAAK,eAAgB;AAAA,UACrB;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAC;AAAA,EACF;AACD;",
6
+ "names": ["supportedMatchers"]
7
+ }
@@ -1,14 +1,31 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var supported_matchers_exports = {};
20
+ __export(supported_matchers_exports, {
21
+ default: () => supported_matchers_default
5
22
  });
6
- exports.default = void 0;
23
+ module.exports = __toCommonJS(supported_matchers_exports);
7
24
  const supportedMatchers = {
8
- error: 'toHaveErrored',
9
- info: 'toHaveInformed',
10
- log: 'toHaveLogged',
11
- warn: 'toHaveWarned'
25
+ error: "toHaveErrored",
26
+ info: "toHaveInformed",
27
+ log: "toHaveLogged",
28
+ warn: "toHaveWarned"
12
29
  };
13
- var _default = exports.default = supportedMatchers;
14
- //# sourceMappingURL=supported-matchers.js.map
30
+ var supported_matchers_default = supportedMatchers;
31
+ //# sourceMappingURL=supported-matchers.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["supportedMatchers","error","info","log","warn","_default","exports","default"],"sources":["@wordpress/jest-console/src/supported-matchers.ts"],"sourcesContent":["const supportedMatchers: Record< string, string > = {\n\terror: 'toHaveErrored',\n\tinfo: 'toHaveInformed',\n\tlog: 'toHaveLogged',\n\twarn: 'toHaveWarned',\n};\n\nexport default supportedMatchers;\n"],"mappings":";;;;;;AAAA,MAAMA,iBAA2C,GAAG;EACnDC,KAAK,EAAE,eAAe;EACtBC,IAAI,EAAE,gBAAgB;EACtBC,GAAG,EAAE,cAAc;EACnBC,IAAI,EAAE;AACP,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaP,iBAAiB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/supported-matchers.ts"],
4
+ "sourcesContent": ["const supportedMatchers: Record< string, string > = {\n\terror: 'toHaveErrored',\n\tinfo: 'toHaveInformed',\n\tlog: 'toHaveLogged',\n\twarn: 'toHaveWarned',\n};\n\nexport default supportedMatchers;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,oBAA8C;AAAA,EACnD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACP;AAEA,IAAO,6BAAQ;",
6
+ "names": []
7
+ }
package/build/types.js CHANGED
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- //# sourceMappingURL=types.js.map
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
17
+ //# sourceMappingURL=types.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/jest-console/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { Mock } from 'jest-mock';\n\n/**\n * Interface for the extended Jest Mock that includes the assertionsNumber property\n */\nexport interface ExtendedMock extends Mock {\n\tassertionsNumber: number;\n}\n\n/**\n * Interface for the matcher result object\n */\nexport interface MatcherResult {\n\tpass: boolean;\n\tmessage: () => string;\n}\n\n/**\n * Interface for the matcher function\n */\nexport type MatcherFunction = (\n\treceived: Record< string, Mock >\n) => MatcherResult;\n\n/**\n * Interface for the matcher function with arguments\n */\nexport type MatcherWithArgsFunction = (\n\treceived: Record< string, Mock >,\n\t...expected: unknown[]\n) => MatcherResult;\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/types.ts"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport type { Mock } from 'jest-mock';\n\n/**\n * Interface for the extended Jest Mock that includes the assertionsNumber property\n */\nexport interface ExtendedMock extends Mock {\n\tassertionsNumber: number;\n}\n\n/**\n * Interface for the matcher result object\n */\nexport interface MatcherResult {\n\tpass: boolean;\n\tmessage: () => string;\n}\n\n/**\n * Interface for the matcher function\n */\nexport type MatcherFunction = (\n\treceived: Record< string, Mock >\n) => MatcherResult;\n\n/**\n * Interface for the matcher function with arguments\n */\nexport type MatcherWithArgsFunction = (\n\treceived: Record< string, Mock >,\n\t...expected: unknown[]\n) => MatcherResult;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -1,2 +1 @@
1
-
2
- //# sourceMappingURL=declarations.d.js.map
1
+ //# sourceMappingURL=declarations.d.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/jest-console/src/declarations.d.ts"],"sourcesContent":["// Definitions originally written by Damien Sorel <https://github.com/mistic100> under MIT license.\n// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/f0b72c12f6b561e4342dc8a1cf87432d2ad40ae7/types/wordpress__jest-console/index.d.ts\n\ndeclare namespace jest {\n\tinterface Matchers< R, T > {\n\t\t/**\n\t\t * Ensure that `console.error` function was called.\n\t\t */\n\t\ttoHaveErrored(): R;\n\n\t\t/**\n\t\t * Ensure that `console.error` function was called with specific arguments.\n\t\t */\n\t\ttoHaveErroredWith( ...args: unknown[] ): R;\n\n\t\t/**\n\t\t * Ensure that `console.info` function was called.\n\t\t */\n\t\ttoHaveInformed(): R;\n\n\t\t/**\n\t\t * Ensure that `console.info` function was called with specific arguments.\n\t\t */\n\t\ttoHaveInformedWith( ...args: unknown[] ): R;\n\n\t\t/**\n\t\t * Ensure that `console.log` function was called.\n\t\t */\n\t\ttoHaveLogged(): R;\n\n\t\t/**\n\t\t * Ensure that `console.log` function was called with specific arguments.\n\t\t */\n\t\ttoHaveLoggedWith( ...args: unknown[] ): R;\n\n\t\t/**\n\t\t * Ensure that `console.warn` function was called.\n\t\t */\n\t\ttoHaveWarned(): R;\n\n\t\t/**\n\t\t * Ensure that `console.warn` function was called with specific arguments.\n\t\t */\n\t\ttoHaveWarnedWith( ...args: unknown[] ): R;\n\t}\n}\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,28 +1,12 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import './matchers';
5
- import supportedMatchers from './supported-matchers';
6
- /**
7
- * Sets spy on the console object's method to make it possible to fail test when method called without assertion.
8
- *
9
- * @param args
10
- */
11
- const setConsoleMethodSpy = args => {
1
+ import "./matchers";
2
+ import supportedMatchers from "./supported-matchers";
3
+ const setConsoleMethodSpy = (args) => {
12
4
  const [methodName, matcherName] = args;
13
5
  const spy = jest.spyOn(console, methodName).mockName(`console.${methodName}`);
14
-
15
- /**
16
- * Resets the spy to its initial state.
17
- */
18
6
  function resetSpy() {
19
7
  spy.mockReset();
20
8
  spy.assertionsNumber = 0;
21
9
  }
22
-
23
- /**
24
- * Verifies that the spy has only been called if expected.
25
- */
26
10
  function assertExpectedCalls() {
27
11
  if (spy.assertionsNumber === 0 && spy.mock.calls.length > 0) {
28
12
  expect(console).not[matcherName]();
@@ -36,4 +20,4 @@ const setConsoleMethodSpy = args => {
36
20
  afterEach(assertExpectedCalls);
37
21
  };
38
22
  Object.entries(supportedMatchers).forEach(setConsoleMethodSpy);
39
- //# sourceMappingURL=index.js.map
23
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["supportedMatchers","setConsoleMethodSpy","args","methodName","matcherName","spy","jest","spyOn","console","mockName","resetSpy","mockReset","assertionsNumber","assertExpectedCalls","mock","calls","length","expect","not","beforeAll","beforeEach","afterEach","Object","entries","forEach"],"sources":["@wordpress/jest-console/src/index.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport './matchers';\nimport supportedMatchers from './supported-matchers';\nimport type { ExtendedMock } from './types';\n\n/**\n * Sets spy on the console object's method to make it possible to fail test when method called without assertion.\n *\n * @param args\n */\nconst setConsoleMethodSpy = ( args: [ string, string ] ) => {\n\tconst [ methodName, matcherName ] = args;\n\tconst spy = jest\n\t\t.spyOn( console, methodName as 'error' | 'info' | 'log' | 'warn' )\n\t\t.mockName( `console.${ methodName }` ) as ExtendedMock;\n\n\t/**\n\t * Resets the spy to its initial state.\n\t */\n\tfunction resetSpy() {\n\t\tspy.mockReset();\n\t\tspy.assertionsNumber = 0;\n\t}\n\n\t/**\n\t * Verifies that the spy has only been called if expected.\n\t */\n\tfunction assertExpectedCalls() {\n\t\tif ( spy.assertionsNumber === 0 && spy.mock.calls.length > 0 ) {\n\t\t\texpect( console ).not[ matcherName ]();\n\t\t}\n\t}\n\n\tbeforeAll( resetSpy );\n\n\tbeforeEach( () => {\n\t\tassertExpectedCalls();\n\t\tresetSpy();\n\t} );\n\n\tafterEach( assertExpectedCalls );\n};\n\nObject.entries( supportedMatchers ).forEach( setConsoleMethodSpy );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,YAAY;AACnB,OAAOA,iBAAiB,MAAM,sBAAsB;AAGpD;AACA;AACA;AACA;AACA;AACA,MAAMC,mBAAmB,GAAKC,IAAwB,IAAM;EAC3D,MAAM,CAAEC,UAAU,EAAEC,WAAW,CAAE,GAAGF,IAAI;EACxC,MAAMG,GAAG,GAAGC,IAAI,CACdC,KAAK,CAAEC,OAAO,EAAEL,UAAgD,CAAC,CACjEM,QAAQ,CAAE,WAAYN,UAAU,EAAI,CAAiB;;EAEvD;AACD;AACA;EACC,SAASO,QAAQA,CAAA,EAAG;IACnBL,GAAG,CAACM,SAAS,CAAC,CAAC;IACfN,GAAG,CAACO,gBAAgB,GAAG,CAAC;EACzB;;EAEA;AACD;AACA;EACC,SAASC,mBAAmBA,CAAA,EAAG;IAC9B,IAAKR,GAAG,CAACO,gBAAgB,KAAK,CAAC,IAAIP,GAAG,CAACS,IAAI,CAACC,KAAK,CAACC,MAAM,GAAG,CAAC,EAAG;MAC9DC,MAAM,CAAET,OAAQ,CAAC,CAACU,GAAG,CAAEd,WAAW,CAAE,CAAC,CAAC;IACvC;EACD;EAEAe,SAAS,CAAET,QAAS,CAAC;EAErBU,UAAU,CAAE,MAAM;IACjBP,mBAAmB,CAAC,CAAC;IACrBH,QAAQ,CAAC,CAAC;EACX,CAAE,CAAC;EAEHW,SAAS,CAAER,mBAAoB,CAAC;AACjC,CAAC;AAEDS,MAAM,CAACC,OAAO,CAAEvB,iBAAkB,CAAC,CAACwB,OAAO,CAAEvB,mBAAoB,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport './matchers';\nimport supportedMatchers from './supported-matchers';\nimport type { ExtendedMock } from './types';\n\n/**\n * Sets spy on the console object's method to make it possible to fail test when method called without assertion.\n *\n * @param args\n */\nconst setConsoleMethodSpy = ( args: [ string, string ] ) => {\n\tconst [ methodName, matcherName ] = args;\n\tconst spy = jest\n\t\t.spyOn( console, methodName as 'error' | 'info' | 'log' | 'warn' )\n\t\t.mockName( `console.${ methodName }` ) as ExtendedMock;\n\n\t/**\n\t * Resets the spy to its initial state.\n\t */\n\tfunction resetSpy() {\n\t\tspy.mockReset();\n\t\tspy.assertionsNumber = 0;\n\t}\n\n\t/**\n\t * Verifies that the spy has only been called if expected.\n\t */\n\tfunction assertExpectedCalls() {\n\t\tif ( spy.assertionsNumber === 0 && spy.mock.calls.length > 0 ) {\n\t\t\texpect( console ).not[ matcherName ]();\n\t\t}\n\t}\n\n\tbeforeAll( resetSpy );\n\n\tbeforeEach( () => {\n\t\tassertExpectedCalls();\n\t\tresetSpy();\n\t} );\n\n\tafterEach( assertExpectedCalls );\n};\n\nObject.entries( supportedMatchers ).forEach( setConsoleMethodSpy );\n"],
5
+ "mappings": "AAGA,OAAO;AACP,OAAO,uBAAuB;AAQ9B,MAAM,sBAAsB,CAAE,SAA8B;AAC3D,QAAM,CAAE,YAAY,WAAY,IAAI;AACpC,QAAM,MAAM,KACV,MAAO,SAAS,UAAgD,EAChE,SAAU,WAAY,UAAW,EAAG;AAKtC,WAAS,WAAW;AACnB,QAAI,UAAU;AACd,QAAI,mBAAmB;AAAA,EACxB;AAKA,WAAS,sBAAsB;AAC9B,QAAK,IAAI,qBAAqB,KAAK,IAAI,KAAK,MAAM,SAAS,GAAI;AAC9D,aAAQ,OAAQ,EAAE,IAAK,WAAY,EAAE;AAAA,IACtC;AAAA,EACD;AAEA,YAAW,QAAS;AAEpB,aAAY,MAAM;AACjB,wBAAoB;AACpB,aAAS;AAAA,EACV,CAAE;AAEF,YAAW,mBAAoB;AAChC;AAEA,OAAO,QAAS,iBAAkB,EAAE,QAAS,mBAAoB;",
6
+ "names": []
7
+ }
@@ -1,24 +1,22 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { matcherHint, printExpected, printReceived } from 'jest-matcher-utils';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import supportedMatchers from './supported-matchers';
10
- const createErrorMessage = spyInfo => {
11
- const {
12
- spy,
13
- pass,
14
- calls,
15
- matcherName,
16
- methodName,
17
- expected
18
- } = spyInfo;
1
+ import { matcherHint, printExpected, printReceived } from "jest-matcher-utils";
2
+ import supportedMatchers from "./supported-matchers";
3
+ const createErrorMessage = (spyInfo) => {
4
+ const { spy, pass, calls, matcherName, methodName, expected } = spyInfo;
19
5
  const hint = pass ? `.not${matcherName}` : matcherName;
20
- const message = pass ? `Expected mock function not to be called but it was called with:\n${calls.map(printReceived)}` : `Expected mock function to be called${expected ? ` with:\n${printExpected(expected)}\n` : '.'}\nbut it was called with:\n${calls.map(printReceived)}`;
21
- return () => `${matcherHint(hint, spy.getMockName())}` + '\n\n' + message + '\n\n' + `console.${methodName}() should not be used unless explicitly expected\n` + 'See https://www.npmjs.com/package/@wordpress/jest-console for details.';
6
+ const message = pass ? `Expected mock function not to be called but it was called with:
7
+ ${calls.map(
8
+ printReceived
9
+ )}` : `Expected mock function to be called${expected ? ` with:
10
+ ${printExpected(expected)}
11
+ ` : "."}
12
+ but it was called with:
13
+ ${calls.map(printReceived)}`;
14
+ return () => `${matcherHint(hint, spy.getMockName())}
15
+
16
+ ` + message + `
17
+
18
+ console.${methodName}() should not be used unless explicitly expected
19
+ See https://www.npmjs.com/package/@wordpress/jest-console for details.`;
22
20
  };
23
21
  const createSpyInfo = (spy, matcherName, methodName, expected) => {
24
22
  const calls = spy.mock.calls;
@@ -36,24 +34,35 @@ const createSpyInfo = (spy, matcherName, methodName, expected) => {
36
34
  message
37
35
  };
38
36
  };
39
- const createToHaveBeenCalledMatcher = (matcherName, methodName) => received => {
37
+ const createToHaveBeenCalledMatcher = (matcherName, methodName) => (received) => {
40
38
  const spy = received[methodName];
41
39
  const spyInfo = createSpyInfo(spy, matcherName, methodName);
42
40
  spy.assertionsNumber += 1;
43
41
  return spyInfo;
44
42
  };
45
- const createToHaveBeenCalledWith = (matcherName, methodName) => function (received, ...expected) {
43
+ const createToHaveBeenCalledWith = (matcherName, methodName) => function(received, ...expected) {
46
44
  const spy = received[methodName];
47
45
  const spyInfo = createSpyInfo(spy, matcherName, methodName, expected);
48
46
  spy.assertionsNumber += 1;
49
47
  return spyInfo;
50
48
  };
51
- expect.extend(Object.entries(supportedMatchers).reduce((result, [methodName, matcherName]) => {
52
- const matcherNameWith = `${matcherName}With`;
53
- return {
54
- ...result,
55
- [matcherName]: createToHaveBeenCalledMatcher(`.${matcherName}`, methodName),
56
- [matcherNameWith]: createToHaveBeenCalledWith(`.${matcherNameWith}`, methodName)
57
- };
58
- }, {}));
59
- //# sourceMappingURL=matchers.js.map
49
+ expect.extend(
50
+ Object.entries(supportedMatchers).reduce(
51
+ (result, [methodName, matcherName]) => {
52
+ const matcherNameWith = `${matcherName}With`;
53
+ return {
54
+ ...result,
55
+ [matcherName]: createToHaveBeenCalledMatcher(
56
+ `.${matcherName}`,
57
+ methodName
58
+ ),
59
+ [matcherNameWith]: createToHaveBeenCalledWith(
60
+ `.${matcherNameWith}`,
61
+ methodName
62
+ )
63
+ };
64
+ },
65
+ {}
66
+ )
67
+ );
68
+ //# sourceMappingURL=matchers.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["matcherHint","printExpected","printReceived","supportedMatchers","createErrorMessage","spyInfo","spy","pass","calls","matcherName","methodName","expected","hint","message","map","getMockName","createSpyInfo","mock","JSON","stringify","includes","length","createToHaveBeenCalledMatcher","received","assertionsNumber","createToHaveBeenCalledWith","expect","extend","Object","entries","reduce","result","matcherNameWith"],"sources":["@wordpress/jest-console/src/matchers.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport { matcherHint, printExpected, printReceived } from 'jest-matcher-utils';\n\n/**\n * Internal dependencies\n */\nimport supportedMatchers from './supported-matchers';\nimport type { Mock } from 'jest-mock';\nimport type {\n\tExtendedMock,\n\tMatcherFunction,\n\tMatcherResult,\n\tMatcherWithArgsFunction,\n} from './types';\n\ninterface SpyInfo {\n\tspy: Mock;\n\tpass: boolean;\n\tcalls: unknown[][];\n\tmatcherName: string;\n\tmethodName: string;\n\texpected?: unknown[];\n}\n\nconst createErrorMessage = ( spyInfo: SpyInfo ) => {\n\tconst { spy, pass, calls, matcherName, methodName, expected } = spyInfo;\n\tconst hint = pass ? `.not${ matcherName }` : matcherName;\n\tconst message = pass\n\t\t? `Expected mock function not to be called but it was called with:\\n${ calls.map(\n\t\t\t\tprintReceived\n\t\t ) }`\n\t\t: `Expected mock function to be called${\n\t\t\t\texpected ? ` with:\\n${ printExpected( expected ) }\\n` : '.'\n\t\t }\\nbut it was called with:\\n${ calls.map( printReceived ) }`;\n\n\treturn () =>\n\t\t`${ matcherHint( hint, spy.getMockName() ) }` +\n\t\t'\\n\\n' +\n\t\tmessage +\n\t\t'\\n\\n' +\n\t\t`console.${ methodName }() should not be used unless explicitly expected\\n` +\n\t\t'See https://www.npmjs.com/package/@wordpress/jest-console for details.';\n};\n\nconst createSpyInfo = (\n\tspy: Mock,\n\tmatcherName: string,\n\tmethodName: string,\n\texpected?: unknown[]\n) => {\n\tconst calls = spy.mock.calls;\n\n\tconst pass = expected\n\t\t? JSON.stringify( calls ).includes( JSON.stringify( expected ) )\n\t\t: calls.length > 0;\n\n\tconst message = createErrorMessage( {\n\t\tspy,\n\t\tpass,\n\t\tcalls,\n\t\tmatcherName,\n\t\tmethodName,\n\t\texpected,\n\t} );\n\n\treturn {\n\t\tpass,\n\t\tmessage,\n\t};\n};\n\nconst createToHaveBeenCalledMatcher =\n\t( matcherName: string, methodName: string ) =>\n\t( received: Record< string, Mock > ): MatcherResult => {\n\t\tconst spy = received[ methodName ] as ExtendedMock;\n\t\tconst spyInfo = createSpyInfo( spy, matcherName, methodName );\n\t\tspy.assertionsNumber += 1;\n\t\treturn spyInfo;\n\t};\n\nconst createToHaveBeenCalledWith = (\n\tmatcherName: string,\n\tmethodName: string\n) =>\n\tfunction (\n\t\treceived: Record< string, Mock >,\n\t\t...expected: unknown[]\n\t): MatcherResult {\n\t\tconst spy = received[ methodName ] as ExtendedMock;\n\t\tconst spyInfo = createSpyInfo( spy, matcherName, methodName, expected );\n\t\tspy.assertionsNumber += 1;\n\t\treturn spyInfo;\n\t};\n\ntype MatchersObject = Record<\n\tstring,\n\tMatcherFunction | MatcherWithArgsFunction\n>;\n\nexpect.extend(\n\tObject.entries( supportedMatchers ).reduce< MatchersObject >(\n\t\t( result, [ methodName, matcherName ] ) => {\n\t\t\tconst matcherNameWith = `${ matcherName }With`;\n\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\t[ matcherName ]: createToHaveBeenCalledMatcher(\n\t\t\t\t\t`.${ matcherName }`,\n\t\t\t\t\tmethodName\n\t\t\t\t),\n\t\t\t\t[ matcherNameWith ]: createToHaveBeenCalledWith(\n\t\t\t\t\t`.${ matcherNameWith }`,\n\t\t\t\t\tmethodName\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t{}\n\t)\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,aAAa,EAAEC,aAAa,QAAQ,oBAAoB;;AAE9E;AACA;AACA;AACA,OAAOC,iBAAiB,MAAM,sBAAsB;AAkBpD,MAAMC,kBAAkB,GAAKC,OAAgB,IAAM;EAClD,MAAM;IAAEC,GAAG;IAAEC,IAAI;IAAEC,KAAK;IAAEC,WAAW;IAAEC,UAAU;IAAEC;EAAS,CAAC,GAAGN,OAAO;EACvE,MAAMO,IAAI,GAAGL,IAAI,GAAG,OAAQE,WAAW,EAAG,GAAGA,WAAW;EACxD,MAAMI,OAAO,GAAGN,IAAI,GACjB,oEAAqEC,KAAK,CAACM,GAAG,CAC9EZ,aACA,CAAC,EAAG,GACJ,sCACAS,QAAQ,GAAG,WAAYV,aAAa,CAAEU,QAAS,CAAC,IAAK,GAAG,GAAG,8BAC5BH,KAAK,CAACM,GAAG,CAAEZ,aAAc,CAAC,EAAG;EAE/D,OAAO,MACN,GAAIF,WAAW,CAAEY,IAAI,EAAEN,GAAG,CAACS,WAAW,CAAC,CAAE,CAAC,EAAG,GAC7C,MAAM,GACNF,OAAO,GACP,MAAM,GACN,WAAYH,UAAU,oDAAqD,GAC3E,wEAAwE;AAC1E,CAAC;AAED,MAAMM,aAAa,GAAGA,CACrBV,GAAS,EACTG,WAAmB,EACnBC,UAAkB,EAClBC,QAAoB,KAChB;EACJ,MAAMH,KAAK,GAAGF,GAAG,CAACW,IAAI,CAACT,KAAK;EAE5B,MAAMD,IAAI,GAAGI,QAAQ,GAClBO,IAAI,CAACC,SAAS,CAAEX,KAAM,CAAC,CAACY,QAAQ,CAAEF,IAAI,CAACC,SAAS,CAAER,QAAS,CAAE,CAAC,GAC9DH,KAAK,CAACa,MAAM,GAAG,CAAC;EAEnB,MAAMR,OAAO,GAAGT,kBAAkB,CAAE;IACnCE,GAAG;IACHC,IAAI;IACJC,KAAK;IACLC,WAAW;IACXC,UAAU;IACVC;EACD,CAAE,CAAC;EAEH,OAAO;IACNJ,IAAI;IACJM;EACD,CAAC;AACF,CAAC;AAED,MAAMS,6BAA6B,GAClCA,CAAEb,WAAmB,EAAEC,UAAkB,KACvCa,QAAgC,IAAqB;EACtD,MAAMjB,GAAG,GAAGiB,QAAQ,CAAEb,UAAU,CAAkB;EAClD,MAAML,OAAO,GAAGW,aAAa,CAAEV,GAAG,EAAEG,WAAW,EAAEC,UAAW,CAAC;EAC7DJ,GAAG,CAACkB,gBAAgB,IAAI,CAAC;EACzB,OAAOnB,OAAO;AACf,CAAC;AAEF,MAAMoB,0BAA0B,GAAGA,CAClChB,WAAmB,EACnBC,UAAkB,KAElB,UACCa,QAAgC,EAChC,GAAGZ,QAAmB,EACN;EAChB,MAAML,GAAG,GAAGiB,QAAQ,CAAEb,UAAU,CAAkB;EAClD,MAAML,OAAO,GAAGW,aAAa,CAAEV,GAAG,EAAEG,WAAW,EAAEC,UAAU,EAAEC,QAAS,CAAC;EACvEL,GAAG,CAACkB,gBAAgB,IAAI,CAAC;EACzB,OAAOnB,OAAO;AACf,CAAC;AAOFqB,MAAM,CAACC,MAAM,CACZC,MAAM,CAACC,OAAO,CAAE1B,iBAAkB,CAAC,CAAC2B,MAAM,CACzC,CAAEC,MAAM,EAAE,CAAErB,UAAU,EAAED,WAAW,CAAE,KAAM;EAC1C,MAAMuB,eAAe,GAAG,GAAIvB,WAAW,MAAO;EAE9C,OAAO;IACN,GAAGsB,MAAM;IACT,CAAEtB,WAAW,GAAIa,6BAA6B,CAC7C,IAAKb,WAAW,EAAG,EACnBC,UACD,CAAC;IACD,CAAEsB,eAAe,GAAIP,0BAA0B,CAC9C,IAAKO,eAAe,EAAG,EACvBtB,UACD;EACD,CAAC;AACF,CAAC,EACD,CAAC,CACF,CACD,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/matchers.ts"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { matcherHint, printExpected, printReceived } from 'jest-matcher-utils';\n\n/**\n * Internal dependencies\n */\nimport supportedMatchers from './supported-matchers';\nimport type { Mock } from 'jest-mock';\nimport type {\n\tExtendedMock,\n\tMatcherFunction,\n\tMatcherResult,\n\tMatcherWithArgsFunction,\n} from './types';\n\ninterface SpyInfo {\n\tspy: Mock;\n\tpass: boolean;\n\tcalls: unknown[][];\n\tmatcherName: string;\n\tmethodName: string;\n\texpected?: unknown[];\n}\n\nconst createErrorMessage = ( spyInfo: SpyInfo ) => {\n\tconst { spy, pass, calls, matcherName, methodName, expected } = spyInfo;\n\tconst hint = pass ? `.not${ matcherName }` : matcherName;\n\tconst message = pass\n\t\t? `Expected mock function not to be called but it was called with:\\n${ calls.map(\n\t\t\t\tprintReceived\n\t\t ) }`\n\t\t: `Expected mock function to be called${\n\t\t\t\texpected ? ` with:\\n${ printExpected( expected ) }\\n` : '.'\n\t\t }\\nbut it was called with:\\n${ calls.map( printReceived ) }`;\n\n\treturn () =>\n\t\t`${ matcherHint( hint, spy.getMockName() ) }` +\n\t\t'\\n\\n' +\n\t\tmessage +\n\t\t'\\n\\n' +\n\t\t`console.${ methodName }() should not be used unless explicitly expected\\n` +\n\t\t'See https://www.npmjs.com/package/@wordpress/jest-console for details.';\n};\n\nconst createSpyInfo = (\n\tspy: Mock,\n\tmatcherName: string,\n\tmethodName: string,\n\texpected?: unknown[]\n) => {\n\tconst calls = spy.mock.calls;\n\n\tconst pass = expected\n\t\t? JSON.stringify( calls ).includes( JSON.stringify( expected ) )\n\t\t: calls.length > 0;\n\n\tconst message = createErrorMessage( {\n\t\tspy,\n\t\tpass,\n\t\tcalls,\n\t\tmatcherName,\n\t\tmethodName,\n\t\texpected,\n\t} );\n\n\treturn {\n\t\tpass,\n\t\tmessage,\n\t};\n};\n\nconst createToHaveBeenCalledMatcher =\n\t( matcherName: string, methodName: string ) =>\n\t( received: Record< string, Mock > ): MatcherResult => {\n\t\tconst spy = received[ methodName ] as ExtendedMock;\n\t\tconst spyInfo = createSpyInfo( spy, matcherName, methodName );\n\t\tspy.assertionsNumber += 1;\n\t\treturn spyInfo;\n\t};\n\nconst createToHaveBeenCalledWith = (\n\tmatcherName: string,\n\tmethodName: string\n) =>\n\tfunction (\n\t\treceived: Record< string, Mock >,\n\t\t...expected: unknown[]\n\t): MatcherResult {\n\t\tconst spy = received[ methodName ] as ExtendedMock;\n\t\tconst spyInfo = createSpyInfo( spy, matcherName, methodName, expected );\n\t\tspy.assertionsNumber += 1;\n\t\treturn spyInfo;\n\t};\n\ntype MatchersObject = Record<\n\tstring,\n\tMatcherFunction | MatcherWithArgsFunction\n>;\n\nexpect.extend(\n\tObject.entries( supportedMatchers ).reduce< MatchersObject >(\n\t\t( result, [ methodName, matcherName ] ) => {\n\t\t\tconst matcherNameWith = `${ matcherName }With`;\n\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\t[ matcherName ]: createToHaveBeenCalledMatcher(\n\t\t\t\t\t`.${ matcherName }`,\n\t\t\t\t\tmethodName\n\t\t\t\t),\n\t\t\t\t[ matcherNameWith ]: createToHaveBeenCalledWith(\n\t\t\t\t\t`.${ matcherNameWith }`,\n\t\t\t\t\tmethodName\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t{}\n\t)\n);\n"],
5
+ "mappings": "AAGA,SAAS,aAAa,eAAe,qBAAqB;AAK1D,OAAO,uBAAuB;AAkB9B,MAAM,qBAAqB,CAAE,YAAsB;AAClD,QAAM,EAAE,KAAK,MAAM,OAAO,aAAa,YAAY,SAAS,IAAI;AAChE,QAAM,OAAO,OAAO,OAAQ,WAAY,KAAK;AAC7C,QAAM,UAAU,OACb;AAAA,EAAqE,MAAM;AAAA,IAC3E;AAAA,EACA,CAAE,KACF,sCACA,WAAW;AAAA,EAAY,cAAe,QAAS,CAAE;AAAA,IAAO,GACxD;AAAA;AAAA,EAA+B,MAAM,IAAK,aAAc,CAAE;AAE7D,SAAO,MACN,GAAI,YAAa,MAAM,IAAI,YAAY,CAAE,CAAE;AAAA;AAAA,IAE3C,UACA;AAAA;AAAA,UACY,UAAW;AAAA;AAEzB;AAEA,MAAM,gBAAgB,CACrB,KACA,aACA,YACA,aACI;AACJ,QAAM,QAAQ,IAAI,KAAK;AAEvB,QAAM,OAAO,WACV,KAAK,UAAW,KAAM,EAAE,SAAU,KAAK,UAAW,QAAS,CAAE,IAC7D,MAAM,SAAS;AAElB,QAAM,UAAU,mBAAoB;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SAAO;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAEA,MAAM,gCACL,CAAE,aAAqB,eACvB,CAAE,aAAqD;AACtD,QAAM,MAAM,SAAU,UAAW;AACjC,QAAM,UAAU,cAAe,KAAK,aAAa,UAAW;AAC5D,MAAI,oBAAoB;AACxB,SAAO;AACR;AAED,MAAM,6BAA6B,CAClC,aACA,eAEA,SACC,aACG,UACa;AAChB,QAAM,MAAM,SAAU,UAAW;AACjC,QAAM,UAAU,cAAe,KAAK,aAAa,YAAY,QAAS;AACtE,MAAI,oBAAoB;AACxB,SAAO;AACR;AAOD,OAAO;AAAA,EACN,OAAO,QAAS,iBAAkB,EAAE;AAAA,IACnC,CAAE,QAAQ,CAAE,YAAY,WAAY,MAAO;AAC1C,YAAM,kBAAkB,GAAI,WAAY;AAExC,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,WAAY,GAAG;AAAA,UAChB,IAAK,WAAY;AAAA,UACjB;AAAA,QACD;AAAA,QACA,CAAE,eAAgB,GAAG;AAAA,UACpB,IAAK,eAAgB;AAAA,UACrB;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAC;AAAA,EACF;AACD;",
6
+ "names": []
7
+ }
@@ -1,8 +1,11 @@
1
1
  const supportedMatchers = {
2
- error: 'toHaveErrored',
3
- info: 'toHaveInformed',
4
- log: 'toHaveLogged',
5
- warn: 'toHaveWarned'
2
+ error: "toHaveErrored",
3
+ info: "toHaveInformed",
4
+ log: "toHaveLogged",
5
+ warn: "toHaveWarned"
6
6
  };
7
- export default supportedMatchers;
8
- //# sourceMappingURL=supported-matchers.js.map
7
+ var supported_matchers_default = supportedMatchers;
8
+ export {
9
+ supported_matchers_default as default
10
+ };
11
+ //# sourceMappingURL=supported-matchers.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["supportedMatchers","error","info","log","warn"],"sources":["@wordpress/jest-console/src/supported-matchers.ts"],"sourcesContent":["const supportedMatchers: Record< string, string > = {\n\terror: 'toHaveErrored',\n\tinfo: 'toHaveInformed',\n\tlog: 'toHaveLogged',\n\twarn: 'toHaveWarned',\n};\n\nexport default supportedMatchers;\n"],"mappings":"AAAA,MAAMA,iBAA2C,GAAG;EACnDC,KAAK,EAAE,eAAe;EACtBC,IAAI,EAAE,gBAAgB;EACtBC,GAAG,EAAE,cAAc;EACnBC,IAAI,EAAE;AACP,CAAC;AAED,eAAeJ,iBAAiB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/supported-matchers.ts"],
4
+ "sourcesContent": ["const supportedMatchers: Record< string, string > = {\n\terror: 'toHaveErrored',\n\tinfo: 'toHaveInformed',\n\tlog: 'toHaveLogged',\n\twarn: 'toHaveWarned',\n};\n\nexport default supportedMatchers;\n"],
5
+ "mappings": "AAAA,MAAM,oBAA8C;AAAA,EACnD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACP;AAEA,IAAO,6BAAQ;",
6
+ "names": []
7
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
1
+ //# sourceMappingURL=types.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/jest-console/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { Mock } from 'jest-mock';\n\n/**\n * Interface for the extended Jest Mock that includes the assertionsNumber property\n */\nexport interface ExtendedMock extends Mock {\n\tassertionsNumber: number;\n}\n\n/**\n * Interface for the matcher result object\n */\nexport interface MatcherResult {\n\tpass: boolean;\n\tmessage: () => string;\n}\n\n/**\n * Interface for the matcher function\n */\nexport type MatcherFunction = (\n\treceived: Record< string, Mock >\n) => MatcherResult;\n\n/**\n * Interface for the matcher function with arguments\n */\nexport type MatcherWithArgsFunction = (\n\treceived: Record< string, Mock >,\n\t...expected: unknown[]\n) => MatcherResult;\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/jest-console",
3
- "version": "8.32.0",
3
+ "version": "8.32.1-next.ff1cebbba.0",
4
4
  "description": "Custom Jest matchers for the Console object.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,9 +31,16 @@
31
31
  ],
32
32
  "main": "build/index.js",
33
33
  "module": "build-module/index.js",
34
+ "exports": {
35
+ ".": {
36
+ "types": "./build-types/index.d.ts",
37
+ "import": "./build-module/index.js",
38
+ "require": "./build/index.js"
39
+ },
40
+ "./package.json": "./package.json"
41
+ },
34
42
  "types": "build-types",
35
43
  "dependencies": {
36
- "@babel/runtime": "7.25.7",
37
44
  "jest-matcher-utils": "^29.6.2"
38
45
  },
39
46
  "peerDependencies": {
@@ -42,5 +49,5 @@
42
49
  "publishConfig": {
43
50
  "access": "public"
44
51
  },
45
- "gitHead": "a030b4c0e0695239b942c7dc18511782b64f10ed"
52
+ "gitHead": "c5b659710aff01d40d2eb97b211eb2cec9c07d3b"
46
53
  }