Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled
223 lines
5.4 KiB
TypeScript
223 lines
5.4 KiB
TypeScript
import execa from 'execa'
|
|
import { readFile, writeFile } from 'fs/promises'
|
|
import { join } from 'path'
|
|
import { run, useTempDir } from './utils'
|
|
|
|
describe('create-next-app Biome configuration', () => {
|
|
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 match biome.json snapshot', async () => {
|
|
await useTempDir(async (cwd) => {
|
|
const projectName = 'test-biome-snapshot'
|
|
const { exitCode } = await run(
|
|
[
|
|
projectName,
|
|
'--ts',
|
|
'--biome',
|
|
'--no-tailwind',
|
|
'--no-src-dir',
|
|
'--app',
|
|
'--no-import-alias',
|
|
'--no-react-compiler',
|
|
'--no-agents-md',
|
|
'--skip-install',
|
|
],
|
|
nextTgzFilename,
|
|
{ cwd }
|
|
)
|
|
|
|
expect(exitCode).toBe(0)
|
|
|
|
const projectDir = join(cwd, projectName)
|
|
const biomeConfig = await readFile(join(projectDir, 'biome.json'), 'utf8')
|
|
|
|
expect(biomeConfig).toMatchSnapshot()
|
|
})
|
|
})
|
|
|
|
it('should run biome check successfully on generated TypeScript project', async () => {
|
|
await useTempDir(async (cwd) => {
|
|
const projectName = 'test-biome-ts-check'
|
|
const { exitCode } = await run(
|
|
[
|
|
projectName,
|
|
'--ts',
|
|
'--biome',
|
|
'--no-tailwind',
|
|
'--no-src-dir',
|
|
'--app',
|
|
'--no-import-alias',
|
|
'--no-react-compiler',
|
|
'--no-agents-md',
|
|
],
|
|
nextTgzFilename,
|
|
{ cwd }
|
|
)
|
|
|
|
expect(exitCode).toBe(0)
|
|
|
|
const projectDir = join(cwd, projectName)
|
|
|
|
// Run biome check on the generated project
|
|
const { exitCode: biomeExitCode, stdout } = await execa(
|
|
'npm',
|
|
['run', 'lint'],
|
|
{
|
|
cwd: projectDir,
|
|
}
|
|
)
|
|
|
|
expect(biomeExitCode).toBe(0)
|
|
expect(stdout).toContain('Checked')
|
|
})
|
|
})
|
|
|
|
it('should run biome check successfully on generated JavaScript project', async () => {
|
|
await useTempDir(async (cwd) => {
|
|
const projectName = 'test-biome-js-check'
|
|
const { exitCode } = await run(
|
|
[
|
|
projectName,
|
|
'--js',
|
|
'--biome',
|
|
'--no-tailwind',
|
|
'--no-src-dir',
|
|
'--app',
|
|
'--no-import-alias',
|
|
'--no-react-compiler',
|
|
'--no-agents-md',
|
|
],
|
|
nextTgzFilename,
|
|
{ cwd }
|
|
)
|
|
|
|
expect(exitCode).toBe(0)
|
|
|
|
const projectDir = join(cwd, projectName)
|
|
|
|
// Run biome check on the generated project
|
|
const { exitCode: biomeExitCode, stdout } = await execa(
|
|
'npm',
|
|
['run', 'lint'],
|
|
{
|
|
cwd: projectDir,
|
|
}
|
|
)
|
|
|
|
expect(biomeExitCode).toBe(0)
|
|
expect(stdout).toContain('Checked')
|
|
})
|
|
})
|
|
|
|
it('should format code with biome successfully', async () => {
|
|
await useTempDir(async (cwd) => {
|
|
const projectName = 'test-biome-format'
|
|
const { exitCode } = await run(
|
|
[
|
|
projectName,
|
|
'--ts',
|
|
'--biome',
|
|
'--no-tailwind',
|
|
'--no-src-dir',
|
|
'--app',
|
|
'--no-import-alias',
|
|
'--no-react-compiler',
|
|
'--no-agents-md',
|
|
],
|
|
nextTgzFilename,
|
|
{ cwd }
|
|
)
|
|
|
|
expect(exitCode).toBe(0)
|
|
|
|
const projectDir = join(cwd, projectName)
|
|
|
|
// Run biome format on the generated project
|
|
const { exitCode: biomeFormatCode, stdout } = await execa(
|
|
'npm',
|
|
['run', 'format'],
|
|
{
|
|
cwd: projectDir,
|
|
}
|
|
)
|
|
|
|
expect(biomeFormatCode).toBe(0)
|
|
expect(stdout).toContain('Formatted')
|
|
})
|
|
})
|
|
|
|
it('should show errors when biome detects issues', async () => {
|
|
await useTempDir(async (cwd) => {
|
|
const projectName = 'test-biome-errors'
|
|
const { exitCode } = await run(
|
|
[
|
|
projectName,
|
|
'--ts',
|
|
'--biome',
|
|
'--no-tailwind',
|
|
'--no-src-dir',
|
|
'--app',
|
|
'--no-import-alias',
|
|
'--no-react-compiler',
|
|
'--no-agents-md',
|
|
],
|
|
nextTgzFilename,
|
|
{ cwd }
|
|
)
|
|
|
|
expect(exitCode).toBe(0)
|
|
|
|
const projectDir = join(cwd, projectName)
|
|
|
|
// Add a file with linting issues
|
|
const problematicFile = join(projectDir, 'app', 'problematic.tsx')
|
|
await writeFile(
|
|
problematicFile,
|
|
`export default function Component() {
|
|
var unusedVar = 5;
|
|
const a = 1
|
|
const b = 2
|
|
|
|
// Double equals instead of triple
|
|
if (a == b) {
|
|
console.log("test")
|
|
}
|
|
|
|
// Debugger statement
|
|
debugger;
|
|
|
|
return <div>Test</div>
|
|
}`
|
|
)
|
|
|
|
// Run biome check on the project with the problematic file
|
|
try {
|
|
await execa('npm', ['run', 'lint'], {
|
|
cwd: projectDir,
|
|
})
|
|
// If we get here, the command succeeded when it shouldn't have
|
|
expect(true).toBe(false) // Force test to fail
|
|
} catch (error) {
|
|
// The command should fail with exit code 1
|
|
expect(error.exitCode).toBe(1)
|
|
expect(error.stdout + error.stderr).toContain('problematic.tsx')
|
|
// Check for specific error messages
|
|
const output = error.stdout + error.stderr
|
|
expect(output).toMatch(/debugger|no-debugger/)
|
|
}
|
|
})
|
|
})
|
|
})
|