-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
90181d4
commit 1f39cfc
Showing
5 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ReactNode } from 'react' | ||
export default function Root({ children }: { children: ReactNode }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page() { | ||
return <p>hello world</p> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
const nextConfig = {} | ||
|
||
module.exports = nextConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
|
||
describe('no-react', () => { | ||
const { next } = nextTestSetup({ | ||
files: __dirname, | ||
installCommand: 'pnpm remove react react-dom', | ||
}) | ||
|
||
it('should work using cheerio without react, react-dom', async () => { | ||
const $ = await next.render$('/') | ||
expect($('p').text()).toBe('hello world') | ||
}) | ||
}) |
186 changes: 186 additions & 0 deletions
186
test/integration/create-next-app/templates/app-api.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
import { join } from 'node:path' | ||
import { | ||
projectShouldHaveNoGitChanges, | ||
tryNextDev, | ||
run, | ||
useTempDir, | ||
projectFilesShouldExist, | ||
} from '../utils' | ||
import { mapSrcFiles, projectSpecification } from '../lib/specification' | ||
import { projectDepsShouldBe } from '../lib/utils' | ||
|
||
function shouldBeApiTemplateProject({ | ||
cwd, | ||
projectName, | ||
mode, | ||
srcDir, | ||
}: { | ||
cwd: string | ||
projectName: string | ||
mode: 'js' | 'ts' | ||
srcDir?: boolean | ||
}) { | ||
const template = 'app-api' | ||
|
||
projectFilesShouldExist({ | ||
cwd, | ||
projectName, | ||
files: mapSrcFiles(projectSpecification[template][mode].files, srcDir), | ||
}) | ||
|
||
projectDepsShouldBe({ | ||
type: 'dependencies', | ||
cwd, | ||
projectName, | ||
deps: mapSrcFiles(projectSpecification[template][mode].deps, srcDir), | ||
}) | ||
|
||
projectDepsShouldBe({ | ||
type: 'devDependencies', | ||
cwd, | ||
projectName, | ||
deps: mapSrcFiles(projectSpecification[template][mode].devDeps, srcDir), | ||
}) | ||
} | ||
|
||
describe('create-next-app --api (Headless App)', () => { | ||
let nextTgzFilename: string | ||
|
||
// beforeAll(() => { | ||
// if (!process.env.NEXT_TEST_PKG_PATHS) { | ||
// throw new Error('This test needs to be run with `node run-tests.js`.') | ||
// } | ||
|
||
// const pkgPaths = new Map<string, string>( | ||
// JSON.parse(process.env.NEXT_TEST_PKG_PATHS) | ||
// ) | ||
|
||
// nextTgzFilename = pkgPaths.get('next')! | ||
// }) | ||
|
||
it('should create JavaScript project with --js flag', async () => { | ||
await useTempDir(async (cwd) => { | ||
const projectName = 'app-js' | ||
const { exitCode } = await run( | ||
[ | ||
projectName, | ||
'--js', | ||
'--api', | ||
'--no-turbo', | ||
'--no-src-dir', | ||
'--no-import-alias', | ||
], | ||
nextTgzFilename, | ||
{ | ||
cwd, | ||
} | ||
) | ||
|
||
expect(exitCode).toBe(0) | ||
shouldBeApiTemplateProject({ | ||
cwd, | ||
projectName, | ||
mode: 'js', | ||
}) | ||
await tryNextDev({ | ||
cwd, | ||
isApi: true, | ||
Check failure on line 87 in test/integration/create-next-app/templates/app-api.test.ts GitHub Actions / types and precompiled / build
|
||
projectName, | ||
}) | ||
}) | ||
}) | ||
|
||
it('should create TypeScript project with --ts flag', async () => { | ||
await useTempDir(async (cwd) => { | ||
const projectName = 'app-ts' | ||
const { exitCode } = await run( | ||
[ | ||
projectName, | ||
'--ts', | ||
'--api', | ||
'--no-turbo', | ||
'--no-src-dir', | ||
'--no-import-alias', | ||
], | ||
nextTgzFilename, | ||
{ | ||
cwd, | ||
} | ||
) | ||
|
||
expect(exitCode).toBe(0) | ||
shouldBeApiTemplateProject({ | ||
cwd, | ||
projectName, | ||
mode: 'ts', | ||
}) | ||
await tryNextDev({ cwd, isApi: true, projectName }) | ||
Check failure on line 117 in test/integration/create-next-app/templates/app-api.test.ts GitHub Actions / types and precompiled / build
|
||
projectShouldHaveNoGitChanges({ cwd, projectName }) | ||
}) | ||
}) | ||
|
||
it('should create project inside "src" directory with --src-dir flag', async () => { | ||
await useTempDir(async (cwd) => { | ||
const projectName = 'app-src-dir' | ||
const { exitCode } = await run( | ||
[ | ||
projectName, | ||
'--ts', | ||
'--api', | ||
'--no-turbo', | ||
'--src-dir', | ||
'--no-import-alias', | ||
], | ||
nextTgzFilename, | ||
{ | ||
cwd, | ||
stdio: 'inherit', | ||
} | ||
) | ||
|
||
expect(exitCode).toBe(0) | ||
shouldBeApiTemplateProject({ | ||
cwd, | ||
projectName, | ||
mode: 'ts', | ||
srcDir: true, | ||
}) | ||
await tryNextDev({ | ||
cwd, | ||
isApi: true, | ||
Check failure on line 150 in test/integration/create-next-app/templates/app-api.test.ts GitHub Actions / types and precompiled / build
|
||
projectName, | ||
}) | ||
}) | ||
}) | ||
|
||
it('should enable turbopack dev with --turbo flag', async () => { | ||
await useTempDir(async (cwd) => { | ||
const projectName = 'app-turbo' | ||
const { exitCode } = await run( | ||
[ | ||
projectName, | ||
'--ts', | ||
'--api', | ||
'--turbo', | ||
'--no-src-dir', | ||
'--no-import-alias', | ||
], | ||
nextTgzFilename, | ||
{ | ||
cwd, | ||
} | ||
) | ||
|
||
expect(exitCode).toBe(0) | ||
const projectRoot = join(cwd, projectName) | ||
const pkgJson = require(join(projectRoot, 'package.json')) | ||
expect(pkgJson.scripts.dev).toBe('next dev --turbo') | ||
|
||
await tryNextDev({ | ||
cwd, | ||
isApi: true, | ||
Check failure on line 181 in test/integration/create-next-app/templates/app-api.test.ts GitHub Actions / types and precompiled / build
|
||
projectName, | ||
}) | ||
}) | ||
}) | ||
}) |