Skip to content

Commit 8bf1c92

Browse files
authoredMar 8, 2024
test(sanity): use dev aliases in the validation test's worker threads (#5927)
This allows us to run the test suite directly from source, without first having to build
1 parent ec4da46 commit 8bf1c92

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed
 

‎dev/aliases.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const devAliases = {
1818
// because they will be escaped by the jest config
1919
'@sanity/block-tools': './packages/@sanity/block-tools/src',
2020
'@sanity/diff': './packages/@sanity/diff/src',
21+
'@sanity/cli': './packages/@sanity/cli/src',
2122
'@sanity/mutator': './packages/@sanity/mutator/src',
2223
'@sanity/portable-text-editor': './packages/@sanity/portable-text-editor/src',
2324
'@sanity/schema': './packages/@sanity/schema/src/_exports',

‎packages/sanity/src/_internal/cli/threads/__tests__/validateDocuments.test.ts

+5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import {afterAll, beforeAll, describe, expect, it, jest} from '@jest/globals'
22
import {type SanityDocument, type SanityProject} from '@sanity/client'
33
import {evaluate, parse} from 'groq-js'
44
import {createServer, type Server} from 'http'
5+
import path from 'path'
56
import {Worker} from 'worker_threads'
67

8+
import {getAliases} from '../../server/aliases'
79
import {createReceiver, type WorkerChannelReceiver} from '../../util/workerChannels'
810
import {type ValidateDocumentsWorkerData, type ValidationWorkerChannel} from '../validateDocuments'
911

@@ -198,8 +200,11 @@ describe('validateDocuments', () => {
198200

199201
const worker = new Worker(
200202
`
203+
const moduleAlias = require('module-alias')
201204
const { register } = require('esbuild-register/dist/node')
202205
206+
moduleAlias.addAliases(${JSON.stringify(getAliases({monorepo: {path: path.resolve(__dirname, '../../../../../../..')}}))})
207+
203208
const { unregister } = register({
204209
target: 'node18',
205210
format: 'cjs',

0 commit comments

Comments
 (0)
Please sign in to comment.