Skip to content

Commit

Permalink
Add name from createNextDescribe to test directory
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed May 28, 2023
1 parent eabffc1 commit 84839cf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
9 changes: 7 additions & 2 deletions test/lib/create-next-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const { linkPackages } =
require('../../.github/actions/next-stats-action/src/prepare/repo-setup')()

async function createNextInstall({
name = '',
parentSpan = null,
dependencies = null,
installCommand = null,
Expand All @@ -23,7 +24,9 @@ async function createNextInstall({
const origRepoDir = path.join(__dirname, '../../')
const installDir = path.join(
tmpDir,
`next-install-${randomBytes(32).toString('hex')}${dirSuffix}`
`next-install${
name !== '' ? `-${name.toLowerCase().replace(/ /g, '-')}` : ''
}-${randomBytes(32).toString('hex')}${dirSuffix}`
)
let tmpRepoDir
require('console').log('Creating next instance in:')
Expand All @@ -37,7 +40,9 @@ async function createNextInstall({
} else {
tmpRepoDir = path.join(
tmpDir,
`next-repo-${randomBytes(32).toString('hex')}${dirSuffix}`
`next-repo${
name !== '' ? `-${name.toLowerCase().replace(/ /g, '-')}` : ''
}-${randomBytes(32).toString('hex')}${dirSuffix}`
)
require('console').log('Creating temp repo dir', tmpRepoDir)

Expand Down
1 change: 1 addition & 0 deletions test/lib/e2e-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ export function createNextDescribe(
next: NextInstance
}) => void
): void {
options.name = name
describe(name, () => {
if (options.skipDeployment) {
// When the environment is running for deployment tests.
Expand Down
10 changes: 7 additions & 3 deletions test/lib/next-modes/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type PackageJson = {
[key: string]: unknown
}
export interface NextInstanceOpts {
name?: string
files: FileRef | string | { [filename: string]: string | FileRef }
dependencies?: { [name: string]: string }
packageJson?: PackageJson
Expand All @@ -47,6 +48,7 @@ type OmitFirstArgument<F> = F extends (
: never

export class NextInstance {
protected name?: string
protected files: FileRef | { [filename: string]: string | FileRef }
protected nextConfig?: NextConfig
protected installCommand?: InstallCommand
Expand Down Expand Up @@ -120,6 +122,7 @@ export class NextInstance {
skipInstall?: boolean
parentSpan: Span
}) {
const name = this.name
if (this.isDestroyed) {
throw new Error('next instance already destroyed')
}
Expand All @@ -134,9 +137,9 @@ export class NextInstance {
: process.env.NEXT_TEST_DIR || (await fs.realpath(os.tmpdir()))
this.testDir = path.join(
tmpDir,
`next-test-${Date.now()}-${(Math.random() * 1000) | 0}${
this.dirSuffix
}`
`next-test${
name !== '' ? `-${name.toLowerCase().replace(/ /g, '-')}` : ''
}-${Date.now()}-${(Math.random() * 1000) | 0}${this.dirSuffix}`
)

const reactVersion = process.env.NEXT_TEST_REACT_VERSION || 'latest'
Expand Down Expand Up @@ -190,6 +193,7 @@ export class NextInstance {
await fs.copy(process.env.NEXT_TEST_STARTER, this.testDir)
} else if (!skipIsolatedNext) {
this.testDir = await createNextInstall({
name: this.name,
parentSpan: rootSpan,
dependencies: finalDependencies,
installCommand: this.installCommand,
Expand Down

0 comments on commit 84839cf

Please sign in to comment.