@xylabs/vitest-extended 5.0.81 → 5.0.83

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/vitest-extended",
3
- "version": "5.0.81",
3
+ "version": "5.0.83",
4
4
  "description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
5
5
  "keywords": [
6
6
  "log",
@@ -39,10 +39,11 @@
39
39
  "types": "./types.d.ts",
40
40
  "files": [
41
41
  "dist",
42
+ "src",
42
43
  "types.d.ts"
43
44
  ],
44
45
  "dependencies": {
45
- "@xylabs/vitest-matchers": "~5.0.81"
46
+ "@xylabs/vitest-matchers": "~5.0.83"
46
47
  },
47
48
  "devDependencies": {
48
49
  "@xylabs/ts-scripts-yarn3": "~7.4.11",
@@ -0,0 +1,4 @@
1
+ import { matchers } from '@xylabs/vitest-matchers'
2
+ import { expect } from 'vitest'
3
+
4
+ expect.extend(matchers)
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './customMatchers.ts'
@@ -0,0 +1,37 @@
1
+ import '../customMatchers.ts'
2
+
3
+ import {
4
+ describe, expect, it,
5
+ } from 'vitest'
6
+
7
+ describe('vitest-extended matchers', () => {
8
+ it('toBeTrue works', () => {
9
+ expect(true).toBeTrue()
10
+ })
11
+
12
+ it('toBeFalse works', () => {
13
+ expect(false).toBeFalse()
14
+ })
15
+
16
+ it('toBeArray works', () => {
17
+ expect([1, 2]).toBeArray()
18
+ })
19
+
20
+ it('toBeString works', () => {
21
+ expect('hello').toBeString()
22
+ })
23
+
24
+ it('toBeNumber works', () => {
25
+ expect(42).toBeNumber()
26
+ })
27
+
28
+ it('toBeObject works', () => {
29
+ expect({}).toBeObject()
30
+ })
31
+
32
+ it('toBeEmpty works', () => {
33
+ expect([]).toBeEmpty()
34
+ expect('').toBeEmpty()
35
+ expect({}).toBeEmpty()
36
+ })
37
+ })
@@ -0,0 +1,31 @@
1
+ // vitest.customMatchers.d.ts
2
+ import 'vitest'
3
+
4
+ interface CustomMatchers<T = unknown> {
5
+ toBeArray(): T
6
+ toBeArrayOfSize(size: number): T
7
+ toBeEmpty(): T
8
+ toBeFalse(): T
9
+ toBeFunction(): T
10
+ toBeInteger(): T
11
+ toBeNegative(): T
12
+ toBeNumber(): T
13
+ toBeObject(): T
14
+ toBeOneOf(expected: unknown[]): T
15
+ toBePositive(): T
16
+ toBeString(): T
17
+ toBeTrue(): T
18
+ toBeValidDate(): T
19
+ toContainAllKeys(expectedKeys: string[]): T
20
+ toContainAllValues(expectedValues: unknown[]): T
21
+ toContainKey(key: string): T
22
+ toContainValues(expectedValues: unknown[]): T
23
+ toInclude(expected: unknown): T
24
+ toIncludeAllMembers(expected: unknown[]): T
25
+ }
26
+
27
+ // Extend the expect Matchers interface
28
+ declare module 'vitest' {
29
+ interface Assertion<T = unknown> extends CustomMatchers<T> {}
30
+ interface AsymmetricMatchersContaining extends CustomMatchers {}
31
+ }