Skip to content

Commit

Permalink
chore: update nx (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachJW34 authored Jul 1, 2022
1 parent d059cf0 commit 4052e8c
Show file tree
Hide file tree
Showing 47 changed files with 1,942 additions and 674 deletions.
2 changes: 1 addition & 1 deletion apps/docusaurus-e2e/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
displayName: 'docusaurus-e2e',
preset: '../../jest.preset.ts',
preset: '../../jest.preset.js',
coverageDirectory: '../../coverage/apps/docusaurus-e2e',
};
1 change: 1 addition & 0 deletions apps/docusaurus-e2e/project.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/docusaurus-e2e/src",
"targets": {
Expand Down
13 changes: 6 additions & 7 deletions apps/docusaurus-e2e/tests/docusaurus.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import {
ensureNxProject,
runNxCommandAsync,
uniq,
} from '@nrwl/nx-plugin/testing';
import { ensureNxProject, uniq } from '@nrwl/nx-plugin/testing';
import { runNxCommandAsyncStripped } from '@nx-plus/test-utils';

describe('docusaurus e2e', () => {
it('should create and build docusaurus', async () => {
const appName = uniq('docusaurus');
ensureNxProject('@nx-plus/docusaurus', 'dist/libs/docusaurus');
await runNxCommandAsync(`generate @nx-plus/docusaurus:app ${appName}`);
await runNxCommandAsyncStripped(
`generate @nx-plus/docusaurus:app ${appName}`
);

const result = await runNxCommandAsync(`build ${appName}`);
const result = await runNxCommandAsyncStripped(`build ${appName}`);
expect(result.stdout).toContain(
`Success! Generated static files in "dist/apps/${appName}".`
);
Expand Down
2 changes: 1 addition & 1 deletion apps/nuxt-e2e/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
displayName: 'nuxt-e2e',
preset: '../../jest.preset.ts',
preset: '../../jest.preset.js',
coverageDirectory: '../../coverage/apps/nuxt-e2e',
};
1 change: 1 addition & 0 deletions apps/nuxt-e2e/project.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/nuxt-e2e/src",
"targets": {
Expand Down
32 changes: 17 additions & 15 deletions apps/nuxt-e2e/tests/nuxt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { tags } from '@angular-devkit/core';
import {
checkFilesExist,
ensureNxProject,
runNxCommandAsync,
uniq,
updateFile,
} from '@nrwl/nx-plugin/testing';
import { runNxCommandAsyncStripped } from '@nx-plus/test-utils';

describe('nuxt e2e', () => {
beforeAll(() => {
Expand All @@ -14,22 +14,22 @@ describe('nuxt e2e', () => {

it('should generate app', async () => {
const appName = uniq('app');
await runNxCommandAsync(`generate @nx-plus/nuxt:app ${appName}`);
await runNxCommandAsyncStripped(`generate @nx-plus/nuxt:app ${appName}`);

const lintResult = await runNxCommandAsync(`lint ${appName}`);
const lintResult = await runNxCommandAsyncStripped(`lint ${appName}`);
expect(lintResult.stdout).toContain('All files pass linting.');

const testResult = await runNxCommandAsync(`test ${appName}`);
const testResult = await runNxCommandAsyncStripped(`test ${appName}`);
expect(testResult.stderr).toContain(tags.stripIndent`
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
`);

const e2eResult = await runNxCommandAsync(`e2e ${appName}-e2e`);
const e2eResult = await runNxCommandAsyncStripped(`e2e ${appName}-e2e`);
expect(e2eResult.stdout).toContain('All specs passed!');

await runNxCommandAsync(`build ${appName}`);
await runNxCommandAsyncStripped(`build ${appName}`);
expect(() =>
checkFilesExist(
`dist/apps/${appName}/.nuxt/utils.js`,
Expand All @@ -52,30 +52,32 @@ describe('nuxt e2e', () => {
)
).not.toThrow();

const prodE2eResult = await runNxCommandAsync(`e2e ${appName}-e2e --prod`);
const prodE2eResult = await runNxCommandAsyncStripped(
`e2e ${appName}-e2e --prod`
);
expect(prodE2eResult.stdout).toContain('All specs passed!');
}, 300000);

it('should report lint error in index.vue', async () => {
const appName = uniq('app');
await runNxCommandAsync(`generate @nx-plus/nuxt:app ${appName}`);
await runNxCommandAsyncStripped(`generate @nx-plus/nuxt:app ${appName}`);

updateFile(
`apps/${appName}/pages/index.vue`,
'<script lang="ts">{}</script>'
);

const result = await runNxCommandAsync(`lint ${appName}`, {
const result = await runNxCommandAsyncStripped(`lint ${appName}`, {
silenceError: true,
});
expect(result.stderr).toContain('Lint errors found in the listed files.');
}, 300000);

it('should generate static app', async () => {
const appName = uniq('app');
await runNxCommandAsync(`generate @nx-plus/nuxt:app ${appName}`);
await runNxCommandAsyncStripped(`generate @nx-plus/nuxt:app ${appName}`);

await runNxCommandAsync(`static ${appName}`);
await runNxCommandAsyncStripped(`static ${appName}`);
expect(() =>
checkFilesExist(
`dist/apps/${appName}/dist/_nuxt`,
Expand All @@ -90,11 +92,11 @@ describe('nuxt e2e', () => {
describe('--directory subdir', () => {
it('should generate app', async () => {
const appName = uniq('app');
await runNxCommandAsync(
await runNxCommandAsyncStripped(
`generate @nx-plus/nuxt:app ${appName} --directory subdir`
);

await runNxCommandAsync(`build subdir-${appName}`);
await runNxCommandAsyncStripped(`build subdir-${appName}`);
expect(() =>
checkFilesExist(
`dist/apps/subdir/${appName}/.nuxt/utils.js`,
Expand All @@ -120,11 +122,11 @@ describe('nuxt e2e', () => {

it('should generate static app', async () => {
const appName = uniq('app');
await runNxCommandAsync(
await runNxCommandAsyncStripped(
`generate @nx-plus/nuxt:app ${appName} --directory subdir`
);

await runNxCommandAsync(`static subdir-${appName}`);
await runNxCommandAsyncStripped(`static subdir-${appName}`);
expect(() =>
checkFilesExist(
`dist/apps/subdir/${appName}/dist/_nuxt`,
Expand Down
2 changes: 1 addition & 1 deletion apps/vite-e2e/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
displayName: 'vite-e2e',
preset: '../../jest.preset.ts',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
Expand Down
1 change: 1 addition & 0 deletions apps/vite-e2e/project.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/vite-e2e/src",
"targets": {
Expand Down
12 changes: 6 additions & 6 deletions apps/vite-e2e/tests/vite.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ import { tags } from '@angular-devkit/core';
import {
checkFilesExist,
ensureNxProject,
runNxCommandAsync,
uniq,
updateFile,
} from '@nrwl/nx-plugin/testing';
import { join } from 'path';
import { runNxCommandAsyncStripped } from '@nx-plus/test-utils';

describe('vite e2e', () => {
it('should create vite app', async () => {
const appName = uniq('vite');
ensureNxProject('@nx-plus/vite', 'dist/libs/vite');
await runNxCommandAsync(`generate @nx-plus/vite:app ${appName}`);
await runNxCommandAsyncStripped(`generate @nx-plus/vite:app ${appName}`);

const lintResult = await runNxCommandAsync(`lint ${appName}`);
const lintResult = await runNxCommandAsyncStripped(`lint ${appName}`);
expect(lintResult.stdout).toContain('All files pass linting.');

const testResult = await runNxCommandAsync(`test ${appName}`);
const testResult = await runNxCommandAsyncStripped(`test ${appName}`);
expect(testResult.stderr).toContain(tags.stripIndent`
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
`);

disableHashing(appName);
await runNxCommandAsync(`build ${appName}`);
await runNxCommandAsyncStripped(`build ${appName}`);
checkFilesExist(
`dist/apps/${appName}/index.html`,
`dist/apps/${appName}/favicon.ico`,
Expand All @@ -34,7 +34,7 @@ describe('vite e2e', () => {
`dist/apps/${appName}/assets/logo.png`
);

const e2eResult = await runNxCommandAsync(`e2e ${appName}-e2e`);
const e2eResult = await runNxCommandAsyncStripped(`e2e ${appName}-e2e`);
expect(e2eResult.stdout).toContain('All specs passed!');
}, 200000);
});
Expand Down
2 changes: 1 addition & 1 deletion apps/vue-e2e/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
displayName: 'vue-e2e',
preset: '../../jest.preset.ts',
preset: '../../jest.preset.js',
coverageDirectory: '../../coverage/apps/vue-e2e',
maxWorkers: 1,
};
1 change: 1 addition & 0 deletions apps/vue-e2e/project.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/vue-e2e/src",
"targets": {
Expand Down
15 changes: 6 additions & 9 deletions apps/vue-e2e/tests/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { tags } from '@angular-devkit/core';
import {
checkFilesExist,
runNxCommandAsync,
tmpProjPath,
} from '@nrwl/nx-plugin/testing';
import { checkFilesExist, tmpProjPath } from '@nrwl/nx-plugin/testing';
import * as cp from 'child_process';
import { runNxCommandAsyncStripped } from '@nx-plus/test-utils';

export async function testGeneratedApp(
appName: string,
Expand All @@ -17,12 +14,12 @@ export async function testGeneratedApp(
}
): Promise<void> {
if (options.lint) {
const lintResult = await runNxCommandAsync(`lint ${appName}`);
const lintResult = await runNxCommandAsyncStripped(`lint ${appName}`);
expect(lintResult.stdout).toContain('All files pass linting.');
}

if (options.test) {
const testResult = await runNxCommandAsync(`test ${appName}`);
const testResult = await runNxCommandAsyncStripped(`test ${appName}`);
expect(testResult.stderr).toContain(tags.stripIndent`
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Expand All @@ -31,12 +28,12 @@ export async function testGeneratedApp(
}

if (options.e2e) {
const e2eResult = await runNxCommandAsync(`e2e ${appName}-e2e`);
const e2eResult = await runNxCommandAsyncStripped(`e2e ${appName}-e2e`);
expect(e2eResult.stdout).toContain('All specs passed!');
}

if (options.build) {
const buildResult = await runNxCommandAsync(`build ${appName}`);
const buildResult = await runNxCommandAsyncStripped(`build ${appName}`);
expect(buildResult.stdout).toContain('Build complete.');
expect(() =>
checkFilesExist(
Expand Down
Loading

0 comments on commit 4052e8c

Please sign in to comment.