Skip to content

Commit

Permalink
chore(test): move @sanity/mutator to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoerge committed Sep 25, 2024
1 parent 09e86a2 commit 09be44d
Show file tree
Hide file tree
Showing 22 changed files with 33 additions and 30 deletions.
4 changes: 0 additions & 4 deletions packages/@sanity/mutator/jest.config.mjs

This file was deleted.

6 changes: 3 additions & 3 deletions packages/@sanity/mutator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"lint": "eslint .",
"perf": "node ./perf/run.js",
"prepublishOnly": "turbo run build",
"test": "jest",
"test": "vitest run",
"watch": "pkg-utils watch"
},
"dependencies": {
Expand All @@ -56,11 +56,11 @@
"lodash": "^4.17.21"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@repo/package.config": "workspace:*",
"@repo/test-config": "workspace:*",
"@types/debug": "^4.1.5",
"@types/lodash": "^4.17.7",
"rimraf": "^3.0.2"
"rimraf": "^3.0.2",
"vitest": "^2.1.1"
}
}
2 changes: 1 addition & 1 deletion packages/@sanity/mutator/test/BufferedDocument.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect, test} from '@jest/globals'
import {expect, test} from 'vitest'

import {BufferedDocumentTester} from './util/BufferedDocumentTester'

Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/mutator/test/Descender.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect, test} from '@jest/globals'
import {expect, test} from 'vitest'

import {Descender} from '../src/jsonpath/Descender'
import {Expression} from '../src/jsonpath/Expression'
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/mutator/test/Document.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {test} from '@jest/globals'
import {test} from 'vitest'

import {DocumentTester} from './util/DocumentTester'

Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/mutator/test/Expression.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect, test} from '@jest/globals'
import {expect, test} from 'vitest'

import {Expression} from '../src/jsonpath/Expression'
import {parseJsonPath} from '../src/jsonpath/parse'
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/mutator/test/Matcher.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect, test} from '@jest/globals'
import {expect, test} from 'vitest'

import {Matcher} from '../src/jsonpath/Matcher'
import {PlainProbe} from '../src/jsonpath/PlainProbe'
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/mutator/test/Mutation.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect, test} from '@jest/globals'
import {expect, test} from 'vitest'

import {Mutation} from '../src/document/Mutation'

Expand Down
6 changes: 3 additions & 3 deletions packages/@sanity/mutator/test/SquashingBuffer.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {expect, jest, test} from '@jest/globals'
import {type PatchMutationOperation} from '@sanity/types'
import {expect, test, vi} from 'vitest'

import {Mutation} from '../src/document/Mutation'
import {SquashingBuffer} from '../src/document/SquashingBuffer'
Expand Down Expand Up @@ -113,7 +113,7 @@ test.each(['create', 'createIfNotExists', 'createOrReplace'])(
'%s defaults to current created at time',
(createFnc) => {
const globalMockDate = new Date('2020-01-01T12:34:55.000Z')
const globalDateSpy = jest.spyOn(global, 'Date').mockReturnValue(globalMockDate)
const globalDateSpy = vi.spyOn(global, 'Date').mockReturnValue(globalMockDate)

const sb = new SquashingBuffer(null)

Expand All @@ -140,7 +140,7 @@ test.each(['create', 'createIfNotExists', 'createOrReplace'])(

test('de-duplicate create respects deletes', () => {
const globalMockDate = new Date('2020-01-01T12:34:55.000Z')
const globalDateSpy = jest.spyOn(global, 'Date').mockReturnValue(globalMockDate)
const globalDateSpy = vi.spyOn(global, 'Date').mockReturnValue(globalMockDate)

const initial = {_id: '1', _type: 'test', a: 'A string value', c: 'Some value'}
const sb = new SquashingBuffer(initial)
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/mutator/test/arrayToJSONMatchPath.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {describe, expect, test} from '@jest/globals'
import {describe, expect, test} from 'vitest'

// Converts an array of simple values (strings, numbers only) to a jsonmatch path string.
import {arrayToJSONMatchPath} from '../src/jsonpath/arrayToJSONMatchPath'
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/mutator/test/descend.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {describe, expect, test} from '@jest/globals'
import {describe, expect, test} from 'vitest'

import {descend} from '../src/jsonpath/descend'
import {parseJsonPath} from '../src/jsonpath/parse'
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/mutator/test/extract.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect, test} from '@jest/globals'
import {expect, test} from 'vitest'

import {extract} from '../src/jsonpath'

Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/mutator/test/extractWithPath.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect, test} from '@jest/globals'
import {expect, test} from 'vitest'

import {extractWithPath} from '../src/jsonpath'

Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/mutator/test/parse.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect, test} from '@jest/globals'
import {expect, test} from 'vitest'

import {parseJsonPath} from '../src/jsonpath/parse'

Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/mutator/test/patch.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {expect, test} from '@jest/globals'
import {cloneDeep} from 'lodash'
import {expect, test} from 'vitest'

import {type Doc} from '../src/document/types'
import {Patcher} from '../src/patch'
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/mutator/test/toPath.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect, test} from '@jest/globals'
import {expect, test} from 'vitest'

import {parseJsonPath} from '../src/jsonpath/parse'
import {toPath} from '../src/jsonpath/toPath'
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/mutator/test/tokenize.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect, test} from '@jest/globals'
import {expect, test} from 'vitest'

import {tokenize} from '../src/jsonpath/tokenize'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {expect} from '@jest/globals'
// A test jig for the BufferedDocument model
import {type PatchMutationOperation} from '@sanity/types'
import debugLogger from 'debug'
import {expect} from 'vitest'

import {BufferedDocument, Mutation} from '../../src/document'
import {type CommitHandlerMessage} from '../../src/document/BufferedDocument'
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/mutator/test/util/DocumentTester.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {expect} from '@jest/globals'
// A test jig for the Document model
import {type PatchMutationOperation} from '@sanity/types'
import {expect} from 'vitest'

import {Document, Mutation} from '../../src/document'
import {type SubmissionResponder} from '../../src/document/Document'
Expand Down
3 changes: 3 additions & 0 deletions packages/@sanity/mutator/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {defineConfig} from '@repo/test-config/vitest'

export default defineConfig()
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion vitest.workspace.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import {defineWorkspace} from 'vitest/config'

export default defineWorkspace(['packages/@sanity/migrate', 'packages/@sanity/block-tools'])
export default defineWorkspace([
'packages/@sanity/migrate',
'packages/@sanity/block-tools',
'packages/@sanity/mutator',
])

0 comments on commit 09be44d

Please sign in to comment.