Skip to content

Commit

Permalink
test(sanity): use dev aliases in the validation test's worker threads (
Browse files Browse the repository at this point in the history
…#5927)

This allows us to run the test suite directly from source, without first having to build
  • Loading branch information
bjoerge authored Mar 8, 2024
1 parent ec4da46 commit 8bf1c92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions dev/aliases.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const devAliases = {
// because they will be escaped by the jest config
'@sanity/block-tools': './packages/@sanity/block-tools/src',
'@sanity/diff': './packages/@sanity/diff/src',
'@sanity/cli': './packages/@sanity/cli/src',
'@sanity/mutator': './packages/@sanity/mutator/src',
'@sanity/portable-text-editor': './packages/@sanity/portable-text-editor/src',
'@sanity/schema': './packages/@sanity/schema/src/_exports',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import {afterAll, beforeAll, describe, expect, it, jest} from '@jest/globals'
import {type SanityDocument, type SanityProject} from '@sanity/client'
import {evaluate, parse} from 'groq-js'
import {createServer, type Server} from 'http'
import path from 'path'
import {Worker} from 'worker_threads'

import {getAliases} from '../../server/aliases'
import {createReceiver, type WorkerChannelReceiver} from '../../util/workerChannels'
import {type ValidateDocumentsWorkerData, type ValidationWorkerChannel} from '../validateDocuments'

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

const worker = new Worker(
`
const moduleAlias = require('module-alias')
const { register } = require('esbuild-register/dist/node')
moduleAlias.addAliases(${JSON.stringify(getAliases({monorepo: {path: path.resolve(__dirname, '../../../../../../..')}}))})
const { unregister } = register({
target: 'node18',
format: 'cjs',
Expand Down

0 comments on commit 8bf1c92

Please sign in to comment.