Skip to content
Source
Sign inSign up
TanStack/cli
Open History to see the last commit

edge-import.test.ts

56 lines1.4 KB

1import { afterEach, describe, expect, it, vi } from 'vitest'
2​
3const blockedModules = [
4 'node:fs',
5 'node:fs/promises',
6 'node:path',
7 'node:url',
8 'execa',
9]
10​
11describe('@tanstack/create/edge import', () => {
12 afterEach(() => {
13 for (const moduleName of blockedModules) {
14 vi.doUnmock(moduleName)
15 }
16 vi.resetModules()
17 })
18​
19 it('does not import Node-only modules', async () => {
20 vi.resetModules()
21 for (const moduleName of blockedModules) {
22 vi.doMock(moduleName, () => {
23 throw new Error(`${moduleName} is unavailable`)
24 })
25 }
26​
27 const edge = await import('../src/edge.js')
28​
29 expect(edge.getFrameworkById('react')?.id).toBe('react')
30 })
31})
32​
33describe('@tanstack/create/worker import', () => {
34 afterEach(() => {
35 for (const moduleName of blockedModules) {
36 vi.doUnmock(moduleName)
37 }
38 vi.resetModules()
39 })
40​
41 it('does not import Node-only modules or the bundled manifest', async () => {
42 vi.resetModules()
43 for (const moduleName of blockedModules) {
44 vi.doMock(moduleName, () => {
45 throw new Error(`${moduleName} is unavailable`)
46 })
47 }
48 vi.doMock('../src/generated/create-manifest.js', () => {
49 throw new Error('full manifest should not be imported')
50 })
51​
52 const worker = await import('../src/worker.js')
53​
54 expect(typeof worker.createWorkerCreate).toBe('function')
55 })
56})