Skip to content

Commit d1a0b78

Browse files
committed
chore: update tests
1 parent 4640121 commit d1a0b78

30 files changed

+476
-75
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"workspaces": [
4141
"./cli/*",
4242
"./packages/*",
43-
"./templates/*"
43+
"./templates/*",
44+
"./tests/*"
4445
],
4546
"dependencies": {
4647
"@tanstack/config": "^0.16.2"

packages/cta-core/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
"url": "https://github.com/sponsors/tannerlinsley"
2121
},
2222
"keywords": [
23-
"react",
2423
"tanstack",
2524
"router",
26-
"create-react-app"
25+
"create-tsrouter-app"
2726
],
2827
"author": "Jack Herrington <[email protected]>",
2928
"license": "MIT",

packages/cta-engine/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
"url": "https://github.com/sponsors/tannerlinsley"
2121
},
2222
"keywords": [
23-
"react",
2423
"tanstack",
2524
"router",
26-
"create-react-app"
25+
"create-tsrouter-app"
2726
],
2827
"author": "Jack Herrington <[email protected]>",
2928
"license": "MIT",

packages/cta-engine/src/create-app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,6 @@ Use the following commands to start your app:
761761
% cd ${options.projectName}
762762
% ${startCommand}
763763
764-
Please check the README.md for more information on testing, styling, adding routes, react-query, etc.${errorStatement}`)
764+
Please check the README.md for more information on testing, styling, adding routes, etc.${errorStatement}`)
765765
}
766766
}

pnpm-lock.yaml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ packages:
22
- 'packages/*'
33
- 'cli/*'
44
- 'templates/*'
5+
- 'tests/*'

tests/cra.test.ts renamed to tests/integration-tests/cra.test.ts

Lines changed: 83 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
import { describe, expect, test } from 'vitest'
22

3-
import { createApp } from '../src/create-app.js'
4-
import { finalizeAddOns } from '../src/add-ons.js';
3+
import { createApp } from '@tanstack/cta-engine'
4+
import { finalizeAddOns, getFrameworkById } from '@tanstack/cta-core'
5+
6+
import { register as registerReactCra } from '@tanstack/cta-templates-react-cra'
7+
import { register as registerSolid } from '@tanstack/cta-templates-solid'
8+
59
import { cleanupOutput, createTestEnvironment } from './test-utilities.js'
610

11+
registerReactCra()
12+
registerSolid()
13+
714
describe('React Templates', () => {
815
test('code router in javascript on npm', async () => {
916
const projectName = 'TEST'
1017
const { environment, output } = createTestEnvironment(projectName)
18+
const framework = getFrameworkById('react-cra')!
1119
await createApp(
1220
{
1321
addOns: false,
14-
framework: 'react',
22+
framework,
1523
chosenAddOns: [],
1624
git: true,
1725
mode: 'code-router',
@@ -36,10 +44,11 @@ describe('React Templates', () => {
3644
test('code router in typescript on npm', async () => {
3745
const projectName = 'TEST'
3846
const { environment, output } = createTestEnvironment(projectName)
47+
const framework = getFrameworkById('react-cra')!
3948
await createApp(
4049
{
4150
addOns: false,
42-
framework: 'react',
51+
framework,
4352
chosenAddOns: [],
4453
git: true,
4554
mode: 'code-router',
@@ -64,10 +73,11 @@ describe('React Templates', () => {
6473
test('file router on npm', async () => {
6574
const projectName = 'TEST'
6675
const { environment, output } = createTestEnvironment(projectName)
76+
const framework = getFrameworkById('react-cra')!
6777
await createApp(
6878
{
6979
addOns: false,
70-
framework: 'react',
80+
framework,
7181
chosenAddOns: [],
7282
git: true,
7383
mode: 'file-router',
@@ -92,10 +102,11 @@ describe('React Templates', () => {
92102
test('file router with tailwind on npm', async () => {
93103
const projectName = 'TEST'
94104
const { environment, output } = createTestEnvironment(projectName)
105+
const framework = getFrameworkById('react-cra')!
95106
await createApp(
96107
{
97108
addOns: false,
98-
framework: 'react',
109+
framework,
99110
chosenAddOns: [],
100111
git: true,
101112
mode: 'file-router',
@@ -117,45 +128,46 @@ describe('React Templates', () => {
117128
)
118129
})
119130

120-
test('file router with add-on start on npm', async () => {
121-
const projectName = 'TEST';
122-
const framework = 'react'
123-
const template = 'file-router'
124-
const { environment, output } = createTestEnvironment(projectName);
125-
await createApp(
126-
{
127-
addOns: true,
128-
framework,
129-
chosenAddOns: await finalizeAddOns(framework, template, ['start']),
130-
git: true,
131-
mode: template,
132-
packageManager: 'npm',
133-
projectName,
134-
tailwind: true,
135-
toolchain: 'none',
136-
typescript: true,
137-
variableValues: {},
138-
},
139-
{
140-
silent: true,
141-
environment,
142-
},
143-
);
144-
cleanupOutput(output);
145-
await expect(JSON.stringify(output, null, 2)).toMatchFileSnapshot(
146-
'./snapshots/cra/cr-ts-start-npm.json',
147-
);
148-
});
131+
test('file router with add-on start on npm', async () => {
132+
const projectName = 'TEST'
133+
const framework = getFrameworkById('react-cra')!
134+
const template = 'file-router'
135+
const { environment, output } = createTestEnvironment(projectName)
136+
await createApp(
137+
{
138+
addOns: true,
139+
framework,
140+
chosenAddOns: await finalizeAddOns(framework, template, ['start']),
141+
git: true,
142+
mode: template,
143+
packageManager: 'npm',
144+
projectName,
145+
tailwind: true,
146+
toolchain: 'none',
147+
typescript: true,
148+
variableValues: {},
149+
},
150+
{
151+
silent: true,
152+
environment,
153+
},
154+
)
155+
cleanupOutput(output)
156+
await expect(JSON.stringify(output, null, 2)).toMatchFileSnapshot(
157+
'./snapshots/cra/cr-ts-start-npm.json',
158+
)
159+
})
149160
})
150161

151162
describe('Solid Templates', () => {
152163
test('code router in javascript on npm', async () => {
153164
const projectName = 'TEST'
154165
const { environment, output } = createTestEnvironment(projectName)
166+
const framework = getFrameworkById('solid')!
155167
await createApp(
156168
{
157169
addOns: false,
158-
framework: 'solid',
170+
framework,
159171
chosenAddOns: [],
160172
git: true,
161173
mode: 'code-router',
@@ -180,10 +192,11 @@ describe('Solid Templates', () => {
180192
test('code router in typescript on npm', async () => {
181193
const projectName = 'TEST'
182194
const { environment, output } = createTestEnvironment(projectName)
195+
const framework = getFrameworkById('solid')!
183196
await createApp(
184197
{
185198
addOns: false,
186-
framework: 'solid',
199+
framework,
187200
chosenAddOns: [],
188201
git: true,
189202
mode: 'code-router',
@@ -208,10 +221,11 @@ describe('Solid Templates', () => {
208221
test('file router on npm', async () => {
209222
const projectName = 'TEST'
210223
const { environment, output } = createTestEnvironment(projectName)
224+
const framework = getFrameworkById('solid')!
211225
await createApp(
212226
{
213227
addOns: false,
214-
framework: 'solid',
228+
framework,
215229
chosenAddOns: [],
216230
git: true,
217231
mode: 'file-router',
@@ -236,10 +250,11 @@ describe('Solid Templates', () => {
236250
test('file router with tailwind on npm', async () => {
237251
const projectName = 'TEST'
238252
const { environment, output } = createTestEnvironment(projectName)
253+
const framework = getFrameworkById('solid')!
239254
await createApp(
240255
{
241256
addOns: false,
242-
framework: 'solid',
257+
framework,
243258
chosenAddOns: [],
244259
git: true,
245260
mode: 'file-router',
@@ -261,33 +276,33 @@ describe('Solid Templates', () => {
261276
)
262277
})
263278

264-
test('file router with add-on start on npm', async () => {
265-
const projectName = 'TEST';
266-
const framework = 'solid';
267-
const template = 'file-router';
268-
const { environment, output } = createTestEnvironment(projectName);
269-
await createApp(
270-
{
271-
addOns: true,
272-
framework,
273-
chosenAddOns: await finalizeAddOns(framework, template, ['start']),
274-
git: true,
275-
mode: template,
276-
packageManager: 'npm',
277-
projectName,
278-
tailwind: true,
279-
toolchain: 'none',
280-
typescript: true,
281-
variableValues: {},
282-
},
283-
{
284-
silent: true,
285-
environment,
286-
},
287-
);
288-
cleanupOutput(output);
289-
await expect(JSON.stringify(output, null, 2)).toMatchFileSnapshot(
290-
'./snapshots/cra/solid-cr-ts-start-npm.json',
291-
);
292-
});
279+
test('file router with add-on start on npm', async () => {
280+
const projectName = 'TEST'
281+
const framework = getFrameworkById('solid')!
282+
const template = 'file-router'
283+
const { environment, output } = createTestEnvironment(projectName)
284+
await createApp(
285+
{
286+
addOns: true,
287+
framework,
288+
chosenAddOns: await finalizeAddOns(framework, template, ['start']),
289+
git: true,
290+
mode: template,
291+
packageManager: 'npm',
292+
projectName,
293+
tailwind: true,
294+
toolchain: 'none',
295+
typescript: true,
296+
variableValues: {},
297+
},
298+
{
299+
silent: true,
300+
environment,
301+
},
302+
)
303+
cleanupOutput(output)
304+
await expect(JSON.stringify(output, null, 2)).toMatchFileSnapshot(
305+
'./snapshots/cra/solid-cr-ts-start-npm.json',
306+
)
307+
})
293308
})

tests/integration-tests/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "tanstack-app-creators-tests",
3+
"version": "0.0.1",
4+
"private": true,
5+
"scripts": {
6+
"test": "vitest"
7+
},
8+
"dependencies": {
9+
"vitest": "^3.0.8",
10+
"@tanstack/cta-core": "workspace:*",
11+
"@tanstack/cta-engine": "workspace:*",
12+
"@tanstack/cta-templates-react-cra": "workspace:*",
13+
"@tanstack/cta-templates-solid": "workspace:*"
14+
}
15+
}

tests/integration-tests/snapshots/cra/cr-js-npm.json

Lines changed: 33 additions & 0 deletions
Large diffs are not rendered by default.

tests/integration-tests/snapshots/cra/cr-ts-npm.json

Lines changed: 34 additions & 0 deletions
Large diffs are not rendered by default.

tests/integration-tests/snapshots/cra/cr-ts-start-npm.json

Lines changed: 38 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)