Skip to content

Commit def9474

Browse files
test(qwik-nx): update e2e
1 parent 66eac54 commit def9474

File tree

11 files changed

+31
-60
lines changed

11 files changed

+31
-60
lines changed

e2e/qwik-nx-e2e/tests/application-basic-behavior.suite.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { names } from '@nx/devkit';
2121
export function testApplicationBasicBehavior(generator: 'app' | 'preset') {
2222
const isPreset = generator === 'preset';
2323
const appPathPrefix = isPreset ? 'apps/' : '';
24-
const libPathPrefix = isPreset ? 'libs/' : '';
24+
const libPathPrefix = '';
2525
const devServerPort = 4212;
2626
const previewServerPort = 4232;
2727
describe(`Basic behavior with ${generator} generator`, () => {
@@ -77,7 +77,7 @@ export function testApplicationBasicBehavior(generator: 'app' | 'preset') {
7777
'should create qwik-nx',
7878
async () => {
7979
const result = await runNxCommandAsync(`build ${project}`);
80-
expect(result.stdout).toContain(
80+
expect(stripConsoleColors(result.stdout)).toContain(
8181
`Running type check for the "${project}"..`
8282
);
8383
expect(
@@ -91,7 +91,7 @@ export function testApplicationBasicBehavior(generator: 'app' | 'preset') {
9191
.join('')
9292
.replace(/\n|\s/g, '')
9393
);
94-
expect(result.stdout).toContain(
94+
expect(stripConsoleColors(result.stdout)).toContain(
9595
`Successfully ran target build for project ${project}`
9696
);
9797
expect(() =>
@@ -167,7 +167,7 @@ export function testApplicationBasicBehavior(generator: 'app' | 'preset') {
167167
'unit tests should pass in the created app',
168168
async () => {
169169
const result = await runNxCommandAsync(`test ${project}`);
170-
expect(result.stdout).toContain(
170+
expect(stripConsoleColors(result.stdout)).toContain(
171171
`Successfully ran target test for project ${project}`
172172
);
173173
},
@@ -186,7 +186,7 @@ export function testApplicationBasicBehavior(generator: 'app' | 'preset') {
186186
const result = await runNxCommandAsync(`test ${project}`, {
187187
silenceError: true,
188188
});
189-
expect(result.stdout).toContain(
189+
expect(stripConsoleColors(result.stdout)).toContain(
190190
`Running target test for project ${project} failed`
191191
);
192192
},
@@ -211,7 +211,7 @@ export function testApplicationBasicBehavior(generator: 'app' | 'preset') {
211211
.join('')
212212
.replace(/\n|\s/g, '')
213213
);
214-
expect(result.stdout).toContain(
214+
expect(stripConsoleColors(result.stdout)).toContain(
215215
`Successfully ran target build for project ${project}`
216216
);
217217
},

e2e/qwik-nx-e2e/tests/qwik-nx-cloudflare.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
killPort,
1212
killPorts,
1313
DEFAULT_E2E_TIMEOUT,
14+
stripConsoleColors,
1415
} from '@qwikifiers/e2e/utils';
1516

1617
const CLOUDFLARE_PREVIEW_PORT = 4173;
@@ -49,7 +50,7 @@ describe('qwik nx cloudflare generator', () => {
4950
'should be able to successfully build the application',
5051
async () => {
5152
const result = await runNxCommandAsync(`build-cloudflare ${project}`);
52-
expect(result.stdout).toContain(
53+
expect(stripConsoleColors(result.stdout)).toContain(
5354
`Successfully ran target build for project ${project}`
5455
);
5556
expect(() =>

e2e/qwik-nx-e2e/tests/qwik-nx-netlify.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
killPort,
1212
killPorts,
1313
DEFAULT_E2E_TIMEOUT,
14+
stripConsoleColors,
1415
} from '@qwikifiers/e2e/utils';
1516

1617
const NETLIFY_PREVIEW_PORT = 8888;
@@ -41,7 +42,7 @@ describe('qwik nx netlify generator', () => {
4142
'should be able to successfully build the application',
4243
async () => {
4344
const result = await runNxCommandAsync(`build-netlify ${project}`);
44-
expect(result.stdout).toContain(
45+
expect(stripConsoleColors(result.stdout)).toContain(
4546
`Successfully ran target build for project ${project}`
4647
);
4748
expect(() =>

e2e/qwik-nx-e2e/tests/storybook.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('qwikNxVite plugin e2e', () => {
3636
describe('Applying storybook for existing application', () => {
3737
beforeAll(async () => {
3838
await runNxCommandAsync(
39-
`generate qwik-nx:app ${appProject} --e2eTestRunner=none --no-interactive`
39+
`generate qwik-nx:app --directory=apps/${appProject} --e2eTestRunner=none --no-interactive`
4040
);
4141
await runNxCommandAsync(
4242
`generate qwik-nx:storybook-configuration ${appProject} --no-interactive`
@@ -48,7 +48,7 @@ describe('qwikNxVite plugin e2e', () => {
4848
describe('Applying storybook for existing library', () => {
4949
beforeAll(async () => {
5050
await runNxCommandAsync(
51-
`generate qwik-nx:library ${libProject} --no-interactive`
51+
`generate qwik-nx:library --directory=libs/${libProject} --no-interactive`
5252
);
5353
await runNxCommandAsync(
5454
`generate qwik-nx:storybook-configuration ${libProject} --no-interactive`
@@ -61,7 +61,7 @@ describe('qwikNxVite plugin e2e', () => {
6161
describe('Generating a new library with storybook configuration', () => {
6262
beforeAll(async () => {
6363
await runNxCommandAsync(
64-
`generate qwik-nx:library ${secondLibProject} --storybookConfiguration=true --no-interactive`
64+
`generate qwik-nx:library --directory=libs/${secondLibProject} --storybookConfiguration=true --no-interactive`
6565
);
6666
await addAdditionalStories(secondLibProject);
6767
}, DEFAULT_E2E_TIMEOUT);

e2e/utils/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import * as treeKill from 'tree-kill';
1010
import {
1111
detectPackageManager,
1212
getPackageManagerCommand,
13+
PackageManager,
1314
} from 'nx/src/utils/package-manager';
1415

1516
export const DEFAULT_E2E_TIMEOUT = 3 * 60 * 1000;
@@ -26,7 +27,7 @@ function getAdditionalPackageManagerCommands(): {
2627
createWorkspace: string;
2728
runNx: string;
2829
} {
29-
const pm = detectPackageManager();
30+
const pm = detectPackageManager() as Exclude<PackageManager, 'bun'>;
3031
const [npmMajorVersion] = execSync(`npm -v`).toString().split('.');
3132
const publishedVersion = execSync('npm view nx version');
3233
switch (pm) {

packages/qwik-nx/src/generators/application/files/vite.config.ts__template__

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { qwikNxVite } from 'qwik-nx/plugins';
66

77
export default defineConfig({
88
cacheDir: '<%= offsetFromRoot %>node_modules/.vite/<%= projectRoot %>',
9+
root: '<%= projectRoot %>',
910
plugins: [
1011
qwikNxVite(),
1112
qwikCity(),
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
import { Tree } from '@nx/devkit';
1+
import { joinPathFragments, Tree } from '@nx/devkit';
22
import { QwikWorkspacePresetGeneratorSchema } from './schema';
33

44
export default async function (
55
tree: Tree,
66
options: QwikWorkspacePresetGeneratorSchema
77
) {
8-
options.name = options.qwikAppName ?? options.name;
8+
if (options.qwikAppName.split('/').length === 1) {
9+
options.directory = joinPathFragments('apps', options.qwikAppName);
10+
} else {
11+
options.directory = options.qwikAppName;
12+
}
913
options.style = options.qwikAppStyle ?? options.style;
1014
return await import('../application/generator').then(({ appGenerator }) =>
11-
appGenerator(tree, { ...options, directory: 'apps' })
15+
appGenerator(tree, options)
1216
);
1317
}

packages/qwik-nx/src/generators/preset/schema.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import { Linter } from '@nx/eslint';
22

33
export interface QwikWorkspacePresetGeneratorSchema
44
extends QwikAppGeneratorSchema {
5-
name: string;
65
qwikAppName: string;
76
tags?: string;
8-
directory?: string;
7+
directory: string;
98

109
style: 'css' | 'scss' | 'styl' | 'less' | 'none';
1110
qwikAppStyle: 'css' | 'scss' | 'styl' | 'less' | 'none';

packages/qwik-nx/src/generators/storybook-configuration/generator.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
offsetFromRoot,
1010
ProjectConfiguration,
1111
readProjectConfiguration,
12+
runTasksInSerial,
1213
Tree,
1314
} from '@nx/devkit';
1415
import { Linter } from '@nx/eslint';
@@ -84,7 +85,8 @@ export async function storybookConfigurationGenerator(
8485

8586
const { oldFormat } = await getStorybookVersion();
8687

87-
await configurationGenerator(tree, {
88+
const tasks: GeneratorCallback[] = [];
89+
const addStorybookCallback = await configurationGenerator(tree, {
8890
storybook7UiFramework: '@storybook/html-webpack5',
8991
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
9092
// @ts-ignore
@@ -98,11 +100,14 @@ export async function storybookConfigurationGenerator(
98100
configureCypress: false,
99101
project: projectConfig.name!,
100102
});
103+
tasks.push(addStorybookCallback);
101104

102105
addFiles(tree, normalizedOptions, projectConfig);
103106
await formatFiles(tree);
104107

105-
return addStorybookDependencies(tree);
108+
const addStorybookDependenciesCallback = await addStorybookDependencies(tree);
109+
tasks.push(addStorybookDependenciesCallback);
110+
return runTasksInSerial(...tasks);
106111
}
107112

108113
async function addStorybookDependencies(

packages/qwik-nx/src/utils/add-common-qwik-dependencies.spec.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,4 @@ describe('init generator', () => {
3232
const { devDependencies } = readJson(appTree, 'package.json');
3333
expect(devDependencies['@builder.io/qwik']).toBe('my-version');
3434
});
35-
36-
it('should override existing versions if they are listed in "unsupportedPackageVersions" 1', async () => {
37-
updateJson(appTree, 'package.json', (json) => {
38-
(json.devDependencies ??= {})['vite'] = '5.1.1';
39-
return json;
40-
});
41-
await addCommonQwikDependencies(appTree);
42-
const { devDependencies } = readJson(appTree, 'package.json');
43-
expect(devDependencies['vite']).toBe('~5.2.0');
44-
});
45-
it('should not override existing versions if they are listed in "unsupportedPackageVersions" and have proper version', async () => {
46-
updateJson(appTree, 'package.json', (json) => {
47-
(json.devDependencies ??= {})['vite'] = '5.2.1';
48-
return json;
49-
});
50-
await addCommonQwikDependencies(appTree);
51-
const { devDependencies } = readJson(appTree, 'package.json');
52-
expect(devDependencies['vite']).toBe('5.2.1');
53-
});
5435
});

0 commit comments

Comments
 (0)