diff --git a/jest.config.cjs b/jest.config.cjs deleted file mode 100644 index 2bdb408..0000000 --- a/jest.config.cjs +++ /dev/null @@ -1,6 +0,0 @@ -/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ -module.exports = { - preset: 'ts-jest', - testEnvironment: 'node', - modulePathIgnorePatterns: ['dist'], -}; diff --git a/package.json b/package.json index 136ace3..e1a0ca6 100644 --- a/package.json +++ b/package.json @@ -16,21 +16,17 @@ "scripts": { "build": "rm -rf dist && tsup src/index.ts --format esm,cjs --dts", "watch": "tsc -W", - "test": "jest", - "test:watch": "jest --watch" + "test": "vitest run" }, "devDependencies": { "@tsconfig/node20": "^20.1.4", "@types/assert": "^1.5.10", - "@types/jest": "^29.5.12", "@types/node": "^20.14.9", "assert": "^2.1.0", "bson": "^6.8.0", - "jest": "^29.7.0", - "ts-jest": "^29.1.5", - "ts-node": "^10.9.2", "tsup": "^8.1.0", - "typescript": "^5.5.2" + "typescript": "^5.5.2", + "vitest": "^1.6.0" }, "dependencies": { "@crystallize/js-api-client": "workspace:*", diff --git a/tests/item/item.test.ts b/tests/item/item.test.ts index ab68579..1dcd6c7 100644 --- a/tests/item/item.test.ts +++ b/tests/item/item.test.ts @@ -3,7 +3,7 @@ import { ObjectId } from 'bson'; import { VariablesType } from '@crystallize/js-api-client'; import { Item } from '@crystallize/schema'; import { getItemQuery, item, updateFolderMutation } from '../../src/item/index.js'; - +import { expect, it, vi } from 'vitest'; const mockTenantId = new ObjectId().toString(); const mockItemId = new ObjectId().toString(); @@ -60,7 +60,7 @@ const testCases: testCase[] = [ testCases.forEach((tc) => it(tc.name, async () => { - let mockPimApi = jest.fn().mockResolvedValueOnce({ + let mockPimApi = vi.fn().mockResolvedValueOnce({ item: { get: tc.existingItem || null, }, diff --git a/tests/shape/createMutation.test.ts b/tests/shape/createMutation.test.ts index b932eef..3bae07c 100644 --- a/tests/shape/createMutation.test.ts +++ b/tests/shape/createMutation.test.ts @@ -3,6 +3,7 @@ import { ObjectId } from 'bson'; import { CreateShapeInput } from '@crystallize/schema'; import { createShapeMutation } from '../../src/shape/mutations/create'; import { deepEqual, equal } from 'assert'; +import { expect, it } from 'vitest'; const mockTenantId = new ObjectId().toString(); diff --git a/tests/shape/shape.test.ts b/tests/shape/shape.test.ts index 2967cae..ae7afc0 100644 --- a/tests/shape/shape.test.ts +++ b/tests/shape/shape.test.ts @@ -3,6 +3,7 @@ import { ObjectId } from 'bson'; import { VariablesType } from '@crystallize/js-api-client'; import { Shape } from '@crystallize/schema'; import { createShapeMutation, getShapeQuery, shape, updateShapeMutation } from '../../src/shape'; +import { expect, it, vi } from 'vitest'; const mockTenantId = new ObjectId().toString(); @@ -43,7 +44,6 @@ const testCases: testCase[] = [ }), createShapeMutation({ input: { - tenantId: mockTenantId, identifier: 'some-shape', name: 'Some Shape', type: 'product', @@ -98,7 +98,6 @@ const testCases: testCase[] = [ }), createShapeMutation({ input: { - tenantId: mockTenantId, identifier: 'some-shape', name: 'Some Shape', type: 'product', @@ -159,7 +158,6 @@ const testCases: testCase[] = [ identifier: 'some-shape', }), updateShapeMutation({ - tenantId: mockTenantId, identifier: 'some-shape', input: { name: 'Some Shape 2', @@ -185,7 +183,7 @@ const testCases: testCase[] = [ testCases.forEach((tc) => it(tc.name, async () => { - let mockPimApi = jest.fn().mockResolvedValueOnce({ + let mockPimApi = vi.fn().mockResolvedValueOnce({ shape: { get: tc.existingShape || null, }, diff --git a/tests/shape/updateMutation.test.ts b/tests/shape/updateMutation.test.ts index 773747a..97e29a5 100644 --- a/tests/shape/updateMutation.test.ts +++ b/tests/shape/updateMutation.test.ts @@ -3,6 +3,7 @@ import { ObjectId } from 'bson'; import { UpdateShapeInput } from '@crystallize/schema'; import { updateShapeMutation } from '../../src/shape/mutations/update'; import { deepEqual, equal } from 'assert'; +import { expect, it } from 'vitest'; const mockTenantId = new ObjectId().toString(); @@ -98,7 +99,6 @@ testCases.forEach((tc) => updateShapeMutation({ input: tc.input, identifier: 'shape-identifier', - tenantId: mockTenantId, }), ).toThrow(tc.error); return; @@ -107,7 +107,6 @@ testCases.forEach((tc) => const { query, variables } = updateShapeMutation({ input: tc.input, identifier: 'shape-identifier', - tenantId: mockTenantId, }); const re = / /g; equal( diff --git a/tests/topic/createMutation.test.ts b/tests/topic/createMutation.test.ts index 64812e6..f6b9b11 100644 --- a/tests/topic/createMutation.test.ts +++ b/tests/topic/createMutation.test.ts @@ -1,8 +1,9 @@ import { ZodError } from 'zod'; -import { ObjectId } from 'mongodb'; +import { ObjectId } from 'bson'; import { CreateTopicInput } from '@crystallize/schema'; import { deepEqual, equal } from 'assert'; import { createTopicMutation } from '../../src/topic/mutations/create'; +import { expect, it } from 'vitest'; const mockTenantId = new ObjectId().toString(); diff --git a/tests/topic/topic.test.ts b/tests/topic/topic.test.ts index 555df5e..c9513a5 100644 --- a/tests/topic/topic.test.ts +++ b/tests/topic/topic.test.ts @@ -1,8 +1,9 @@ import { ZodError } from 'zod'; -import { ObjectId } from 'mongodb'; +import { ObjectId } from 'bson'; import { VariablesType } from '@crystallize/js-api-client'; import { Topic } from '@crystallize/schema'; import { getTopicQuery, createTopicMutation, updateTopicMutation, topic } from '../../src/topic'; +import { expect, it, vi } from 'vitest'; interface testCase { name: string; @@ -211,7 +212,7 @@ const testCases: testCase[] = [ testCases.forEach((tc) => it(tc.name, async () => { - let mockPimApi = jest.fn(); + let mockPimApi = vi.fn(); if (tc.existingTopic) { mockPimApi = mockPimApi diff --git a/tests/topic/updateMutation.test.ts b/tests/topic/updateMutation.test.ts index 69aae02..4a2647b 100644 --- a/tests/topic/updateMutation.test.ts +++ b/tests/topic/updateMutation.test.ts @@ -2,6 +2,7 @@ import { ZodError } from 'zod'; import { UpdateTopicInput } from '@crystallize/schema'; import { deepEqual, equal } from 'assert'; import { updateTopicMutation } from '../../src/topic/mutations/update'; +import { expect, it } from 'vitest'; interface testCase { name: string;