Unverified Commit 3010ae10 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Update CNA tests to avoid publish conflict (#57025)

This avoids testing against latest exact canary version as this causes these tests to fail while the publish is still in progress. As a follow-up we can investigate moving this post publish or packing/deploying tarballs to use. 
Co-authored-by: 's avatarSteven <229881+styfle@users.noreply.github.com>
parent 1d9ddfca
...@@ -8,7 +8,7 @@ import fs from 'fs/promises' ...@@ -8,7 +8,7 @@ import fs from 'fs/promises'
import path from 'path' import path from 'path'
import { cyan, bold } from 'picocolors' import { cyan, bold } from 'picocolors'
import { Sema } from 'async-sema' import { Sema } from 'async-sema'
import { version } from '../package.json' import pkg from '../package.json'
import { GetTemplateFileArgs, InstallTemplateArgs } from './types' import { GetTemplateFileArgs, InstallTemplateArgs } from './types'
...@@ -167,6 +167,9 @@ export const installTemplate = async ({ ...@@ -167,6 +167,9 @@ export const installTemplate = async ({
} }
} }
/** Copy the version from package.json or override for tests. */
const version = process.env.NEXT_PRIVATE_TEST_VERSION ?? pkg.version
/** Create a package.json for the new project and write it to disk. */ /** Create a package.json for the new project and write it to disk. */
const packageJson: any = { const packageJson: any = {
name: appName, name: appName,
...@@ -184,7 +187,7 @@ export const installTemplate = async ({ ...@@ -184,7 +187,7 @@ export const installTemplate = async ({
dependencies: { dependencies: {
react: '^18', react: '^18',
'react-dom': '^18', 'react-dom': '^18',
next: process.env.NEXT_PRIVATE_TEST_VERSION ?? version, next: version,
}, },
devDependencies: {}, devDependencies: {},
} }
......
...@@ -13,12 +13,12 @@ import { ...@@ -13,12 +13,12 @@ import {
shouldBeTemplateProject, shouldBeTemplateProject,
spawnExitPromise, spawnExitPromise,
} from './lib/utils' } from './lib/utils'
import { Span } from 'next/dist/trace' //import { Span } from 'next/dist/trace'
import { useTempDir } from '../../lib/use-temp-dir' import { useTempDir } from '../../lib/use-temp-dir'
import { fetchViaHTTP, findPort, killApp, launchApp } from 'next-test-utils' import { fetchViaHTTP, findPort, killApp, launchApp } from 'next-test-utils'
import resolveFrom from 'resolve-from' import resolveFrom from 'resolve-from'
import { createNextInstall } from '../../lib/create-next-install' //import { createNextInstall } from '../../lib/create-next-install'
const startsWithoutError = async ( const startsWithoutError = async (
appDir: string, appDir: string,
...@@ -54,10 +54,13 @@ let testVersion ...@@ -54,10 +54,13 @@ let testVersion
describe('create-next-app --app', () => { describe('create-next-app --app', () => {
beforeAll(async () => { beforeAll(async () => {
if (testVersion) return if (testVersion) return
const span = new Span({ name: 'parent' }) // TODO: investigate moving this post publish or create deployed
testVersion = ( // tarballs to avoid these failing while a publish is in progress
await createNextInstall({ onlyPackages: true, parentSpan: span }) testVersion = 'canary'
).get('next') // const span = new Span({ name: 'parent' })
// testVersion = (
// await createNextInstall({ onlyPackages: true, parentSpan: span })
// ).get('next')
}) })
it('should create TS appDir projects with --ts', async () => { it('should create TS appDir projects with --ts', async () => {
......
...@@ -15,7 +15,7 @@ import { ...@@ -15,7 +15,7 @@ import {
shouldBeTypescriptProject, shouldBeTypescriptProject,
spawnExitPromise, spawnExitPromise,
} from './lib/utils' } from './lib/utils'
import { Span } from 'next/dist/trace' //import { Span } from 'next/dist/trace'
import { useTempDir } from '../../lib/use-temp-dir' import { useTempDir } from '../../lib/use-temp-dir'
import { import {
...@@ -26,7 +26,7 @@ import { ...@@ -26,7 +26,7 @@ import {
launchApp, launchApp,
} from 'next-test-utils' } from 'next-test-utils'
import resolveFrom from 'resolve-from' import resolveFrom from 'resolve-from'
import { createNextInstall } from '../../lib/create-next-install' //import { createNextInstall } from '../../lib/create-next-install'
import ansiEscapes from 'ansi-escapes' import ansiEscapes from 'ansi-escapes'
const startsWithoutError = async ( const startsWithoutError = async (
...@@ -62,10 +62,13 @@ let testVersion ...@@ -62,10 +62,13 @@ let testVersion
describe('create-next-app templates', () => { describe('create-next-app templates', () => {
beforeAll(async () => { beforeAll(async () => {
const span = new Span({ name: 'parent' }) // TODO: investigate moving this post publish or create deployed
testVersion = ( // tarballs to avoid these failing while a publish is in progress
await createNextInstall({ onlyPackages: true, parentSpan: span }) testVersion = 'canary'
).get('next') // const span = new Span({ name: 'parent' })
// testVersion = (
// await createNextInstall({ onlyPackages: true, parentSpan: span })
// ).get('next')
}) })
it('should prompt user to choose if --ts or --js is not provided', async () => { it('should prompt user to choose if --ts or --js is not provided', async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment