Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nextjs): Enable next e2e test #21625

Merged
merged 1 commit into from Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 15 additions & 12 deletions e2e/next-core/src/next-appdir.test.ts
@@ -1,12 +1,12 @@
import {
cleanupProject,
isNotWindows,
killPorts,
newProject,
runCLI,
runE2ETests,
uniq,
updateFile,
} from '@nx/e2e/utils';
import { checkApp } from './utils';

describe('Next.js App Router', () => {
let proj: string;
Expand All @@ -20,8 +20,7 @@ describe('Next.js App Router', () => {

afterAll(() => cleanupProject());

// TODO: enable this when tests are passing again
xit('should be able to generate and build app with default App Router', async () => {
it('should be able to generate and build app with default App Router', async () => {
const appName = uniq('app');
const jsLib = uniq('tslib');

Expand All @@ -31,7 +30,7 @@ describe('Next.js App Router', () => {
runCLI(`generate @nx/js:lib ${jsLib} --no-interactive`);

updateFile(
`apps/${appName}/app/page.tsx`,
`apps/${appName}/src/app/page.tsx`,
`
import React from 'react';
import { ${jsLib} } from '@${proj}/${jsLib}';
Expand All @@ -40,7 +39,7 @@ describe('Next.js App Router', () => {
return (
<p>{${jsLib}()}</p>
);
};
}
`
);

Expand All @@ -58,11 +57,15 @@ describe('Next.js App Router', () => {
`
);

await checkApp(appName, {
checkUnitTest: false,
checkLint: true,
checkE2E: isNotWindows(),
checkExport: false,
});
const lintResults = runCLI(`lint ${appName}`);
expect(lintResults).toContain('Successfully ran target lint');

if (runE2ETests()) {
const e2eResults = runCLI(
`e2e ${appName}-e2e --configuration=production`
);
expect(e2eResults).toContain('Successfully ran target e2e for project');
expect(await killPorts()).toBeTruthy();
}
}, 300_000);
});
10 changes: 3 additions & 7 deletions e2e/next-core/src/next-legacy.test.ts
Expand Up @@ -22,16 +22,11 @@ import { mkdirSync, removeSync } from 'fs-extra';
import { join } from 'path';
import { checkApp } from './utils';

// TODO(crystal, @ndcunningham): Investigate why these tests are failing
xdescribe('@nx/next (legacy)', () => {
describe('@nx/next (legacy)', () => {
let proj: string;
let originalEnv: string;
let packageManager;

afterEach(() => {
cleanupProject();
});

beforeAll(() => {
proj = newProject({
packages: ['@nx/next'],
Expand Down Expand Up @@ -99,7 +94,8 @@ xdescribe('@nx/next (legacy)', () => {
});
}, 1_000_000);

it('should produce a self-contained artifact in dist', async () => {
// Reenable this test once we fix Error: Cannot find module 'ajv/dist/compile/codegen'
xit('should produce a self-contained artifact in dist', async () => {
// Remove apps/libs folder and use packages.
// Allows us to test other integrated monorepo setup that had a regression.
// See: https://github.com/nrwl/nx/issues/16658
Expand Down