@xylabs/vitest-extended 4.3.4 → 4.3.6
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customMatchers.d.ts","sourceRoot":"","sources":["../../src/customMatchers.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,QAAQ;8BACO,OAAO,gBAAgB,MAAM;;;;2BAchC,OAAO;;;;6BACL,OAAO;;;;2BACT,OAAO;;;;wBACV,OAAO;;;;uBAYR,OAAO;;;;
|
|
1
|
+
{"version":3,"file":"customMatchers.d.ts","sourceRoot":"","sources":["../../src/customMatchers.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,QAAQ;8BACO,OAAO,gBAAgB,MAAM;;;;2BAchC,OAAO;;;;6BACL,OAAO;;;;2BACT,OAAO;;;;wBACV,OAAO;;;;uBAYR,OAAO;;;;kCAYI,OAAO,EAAE,YAAY,OAAO,EAAE;;;;CAwB7D,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -43,6 +43,24 @@ var matchers = {
|
|
|
43
43
|
message: () => `expected ${received} to be true but was not true`,
|
|
44
44
|
pass: false
|
|
45
45
|
};
|
|
46
|
+
},
|
|
47
|
+
toIncludeAllMembers(received, expected) {
|
|
48
|
+
if (!Array.isArray(received) || !Array.isArray(expected)) {
|
|
49
|
+
return {
|
|
50
|
+
pass: false,
|
|
51
|
+
message: () => "Expected both received and expected values to be arrays."
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const missingMembers = expected.filter((item) => !received.includes(item));
|
|
55
|
+
return missingMembers.length === 0 ? {
|
|
56
|
+
pass: true,
|
|
57
|
+
message: () => `Expected array not to include all members of ${JSON.stringify(expected)}, but it does.`
|
|
58
|
+
} : {
|
|
59
|
+
pass: false,
|
|
60
|
+
message: () => `Expected array to include all members of ${JSON.stringify(expected)}. Missing members: ${JSON.stringify(
|
|
61
|
+
missingMembers
|
|
62
|
+
)}.`
|
|
63
|
+
};
|
|
46
64
|
}
|
|
47
65
|
};
|
|
48
66
|
expect.extend(matchers);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/customMatchers.ts"],"sourcesContent":["import { expect } from 'vitest'\n\nfunction toBeType(received: unknown, expectedType: string) {\n const pass = typeof received === expectedType && !Number.isNaN(received)\n return pass\n ? {\n message: () => `expected ${received} not to be a ${expectedType}`,\n pass: true,\n }\n : {\n message: () => `expected ${received} to be a ${expectedType}`,\n pass: false,\n }\n}\n\nexport const matchers = {\n toBeArrayOfSize(received: unknown, expectedSize: number) {\n const pass = Array.isArray(received) && received.length === expectedSize\n return pass\n ? {\n message: () => `expected array not to have size ${expectedSize}, but received array of size ${received.length}`,\n pass: true,\n }\n : {\n message: () => Array.isArray(received)\n ? `expected array of size ${expectedSize}, but received array of size ${received.length}`\n : `expected array of size ${expectedSize}, but received a non-array`,\n pass: false,\n }\n },\n toBeNumber: (received: unknown) => toBeType(received, 'number'),\n toBeFunction: (received: unknown) => toBeType(received, 'function'),\n toBeString: (received: unknown) => toBeType(received, 'string'),\n toBeFalse(received: unknown) {\n const pass = received === false\n return pass\n ? {\n message: () => `expected ${received} to be false`,\n pass: true,\n }\n : {\n message: () => `expected ${received} to be false but was not false`,\n pass: false,\n }\n },\n toBeTrue(received: unknown) {\n const pass = received === true\n return pass\n ? {\n message: () => `expected ${received} to be true`,\n pass: true,\n }\n : {\n message: () => `expected ${received} to be true but was not true`,\n pass: false,\n }\n },\n}\n\nexpect.extend(matchers)\n"],"mappings":";AAAA,SAAS,cAAc;AAEvB,SAAS,SAAS,UAAmB,cAAsB;AACzD,QAAM,OAAO,OAAO,aAAa,gBAAgB,CAAC,OAAO,MAAM,QAAQ;AACvE,SAAO,OACH;AAAA,IACE,SAAS,MAAM,YAAY,QAAQ,gBAAgB,YAAY;AAAA,IAC/D,MAAM;AAAA,EACR,IACA;AAAA,IACE,SAAS,MAAM,YAAY,QAAQ,YAAY,YAAY;AAAA,IAC3D,MAAM;AAAA,EACR;AACN;AAEO,IAAM,WAAW;AAAA,EACtB,gBAAgB,UAAmB,cAAsB;AACvD,UAAM,OAAO,MAAM,QAAQ,QAAQ,KAAK,SAAS,WAAW;AAC5D,WAAO,OACH;AAAA,MACE,SAAS,MAAM,mCAAmC,YAAY,gCAAgC,SAAS,MAAM;AAAA,MAC7G,MAAM;AAAA,IACR,IACA;AAAA,MACE,SAAS,MAAM,MAAM,QAAQ,QAAQ,IACjC,0BAA0B,YAAY,gCAAgC,SAAS,MAAM,KACrF,0BAA0B,YAAY;AAAA,MAC1C,MAAM;AAAA,IACR;AAAA,EACN;AAAA,EACA,YAAY,CAAC,aAAsB,SAAS,UAAU,QAAQ;AAAA,EAC9D,cAAc,CAAC,aAAsB,SAAS,UAAU,UAAU;AAAA,EAClE,YAAY,CAAC,aAAsB,SAAS,UAAU,QAAQ;AAAA,EAC9D,UAAU,UAAmB;AAC3B,UAAM,OAAO,aAAa;AAC1B,WAAO,OACH;AAAA,MACE,SAAS,MAAM,YAAY,QAAQ;AAAA,MACnC,MAAM;AAAA,IACR,IACA;AAAA,MACE,SAAS,MAAM,YAAY,QAAQ;AAAA,MACnC,MAAM;AAAA,IACR;AAAA,EACN;AAAA,EACA,SAAS,UAAmB;AAC1B,UAAM,OAAO,aAAa;AAC1B,WAAO,OACH;AAAA,MACE,SAAS,MAAM,YAAY,QAAQ;AAAA,MACnC,MAAM;AAAA,IACR,IACA;AAAA,MACE,SAAS,MAAM,YAAY,QAAQ;AAAA,MACnC,MAAM;AAAA,IACR;AAAA,EACN;AACF;AAEA,OAAO,OAAO,QAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/customMatchers.ts"],"sourcesContent":["import { expect } from 'vitest'\n\nfunction toBeType(received: unknown, expectedType: string) {\n const pass = typeof received === expectedType && !Number.isNaN(received)\n return pass\n ? {\n message: () => `expected ${received} not to be a ${expectedType}`,\n pass: true,\n }\n : {\n message: () => `expected ${received} to be a ${expectedType}`,\n pass: false,\n }\n}\n\nexport const matchers = {\n toBeArrayOfSize(received: unknown, expectedSize: number) {\n const pass = Array.isArray(received) && received.length === expectedSize\n return pass\n ? {\n message: () => `expected array not to have size ${expectedSize}, but received array of size ${received.length}`,\n pass: true,\n }\n : {\n message: () => Array.isArray(received)\n ? `expected array of size ${expectedSize}, but received array of size ${received.length}`\n : `expected array of size ${expectedSize}, but received a non-array`,\n pass: false,\n }\n },\n toBeNumber: (received: unknown) => toBeType(received, 'number'),\n toBeFunction: (received: unknown) => toBeType(received, 'function'),\n toBeString: (received: unknown) => toBeType(received, 'string'),\n toBeFalse(received: unknown) {\n const pass = received === false\n return pass\n ? {\n message: () => `expected ${received} to be false`,\n pass: true,\n }\n : {\n message: () => `expected ${received} to be false but was not false`,\n pass: false,\n }\n },\n toBeTrue(received: unknown) {\n const pass = received === true\n return pass\n ? {\n message: () => `expected ${received} to be true`,\n pass: true,\n }\n : {\n message: () => `expected ${received} to be true but was not true`,\n pass: false,\n }\n },\n toIncludeAllMembers(received: unknown[], expected: unknown[]) {\n if (!Array.isArray(received) || !Array.isArray(expected)) {\n return {\n pass: false,\n message: () => 'Expected both received and expected values to be arrays.',\n }\n }\n\n const missingMembers = expected.filter(item => !received.includes(item))\n\n return missingMembers.length === 0\n ? {\n pass: true,\n message: () =>\n `Expected array not to include all members of ${JSON.stringify(expected)}, but it does.`,\n }\n : {\n pass: false,\n message: () =>\n `Expected array to include all members of ${JSON.stringify(expected)}. Missing members: ${JSON.stringify(\n missingMembers,\n )}.`,\n }\n },\n}\n\nexpect.extend(matchers)\n"],"mappings":";AAAA,SAAS,cAAc;AAEvB,SAAS,SAAS,UAAmB,cAAsB;AACzD,QAAM,OAAO,OAAO,aAAa,gBAAgB,CAAC,OAAO,MAAM,QAAQ;AACvE,SAAO,OACH;AAAA,IACE,SAAS,MAAM,YAAY,QAAQ,gBAAgB,YAAY;AAAA,IAC/D,MAAM;AAAA,EACR,IACA;AAAA,IACE,SAAS,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AQ,CAAC,SAAS,SAAS,IAAI,CAAC;AAEvE,WAAO,eAAe,WAAW,IAC7B;AAAA,MACE,MAAM;AAAA,MACN,SAAS,MACP,gDAAgD,KAAK,UAAU,QAAQ,CAAC;AAAA,IAC5E,IACA;AAAA,MACE,MAAM;AAAA,MACN,SAAS,MACP,4CAA4C,KAAK,UAAU,QAAQ,CAAC,sBAAsB,KAAK;AAAA,QAC7F;AAAA,MACF,CAAC;AAAA,IACL;AAAA,EACN;AACF;AAEA,OAAO,OAAO,QAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/vitest-extended",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.6",
|
|
4
4
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"log",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"packages/**/*"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"vitest": "^2.1.
|
|
44
|
+
"vitest": "^2.1.5"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@xylabs/ts-scripts-yarn3": "^4.2.
|
|
48
|
-
"@xylabs/tsconfig": "^4.2.
|
|
47
|
+
"@xylabs/ts-scripts-yarn3": "^4.2.4",
|
|
48
|
+
"@xylabs/tsconfig": "^4.2.4",
|
|
49
49
|
"typescript": "^5.6.3"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
package/src/customMatchers.ts
CHANGED
|
@@ -55,6 +55,30 @@ export const matchers = {
|
|
|
55
55
|
pass: false,
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
|
+
toIncludeAllMembers(received: unknown[], expected: unknown[]) {
|
|
59
|
+
if (!Array.isArray(received) || !Array.isArray(expected)) {
|
|
60
|
+
return {
|
|
61
|
+
pass: false,
|
|
62
|
+
message: () => 'Expected both received and expected values to be arrays.',
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const missingMembers = expected.filter(item => !received.includes(item))
|
|
67
|
+
|
|
68
|
+
return missingMembers.length === 0
|
|
69
|
+
? {
|
|
70
|
+
pass: true,
|
|
71
|
+
message: () =>
|
|
72
|
+
`Expected array not to include all members of ${JSON.stringify(expected)}, but it does.`,
|
|
73
|
+
}
|
|
74
|
+
: {
|
|
75
|
+
pass: false,
|
|
76
|
+
message: () =>
|
|
77
|
+
`Expected array to include all members of ${JSON.stringify(expected)}. Missing members: ${JSON.stringify(
|
|
78
|
+
missingMembers,
|
|
79
|
+
)}.`,
|
|
80
|
+
}
|
|
81
|
+
},
|
|
58
82
|
}
|
|
59
83
|
|
|
60
84
|
expect.extend(matchers)
|
|
@@ -21,6 +21,10 @@ declare module 'vitest' {
|
|
|
21
21
|
interface Assertion<T = unknown> {
|
|
22
22
|
toBeArrayOfSize(size: number): T
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
interface Assertion<T = unknown> {
|
|
26
|
+
toIncludeAllMembers(received: unknown[], expected: unknown[]): T
|
|
27
|
+
}
|
|
24
28
|
interface expect {
|
|
25
29
|
toBeArrayOfSize(size: number): T
|
|
26
30
|
toBeFalse(): T
|
|
@@ -28,5 +32,6 @@ declare module 'vitest' {
|
|
|
28
32
|
toBeNumber(): T
|
|
29
33
|
toBeString(): T
|
|
30
34
|
toBeTrue(): T
|
|
35
|
+
toIncludeAllMembers(received: unknown[], expected: unknown[]): T
|
|
31
36
|
}
|
|
32
37
|
}
|