Skip to content

Commit

Permalink
Turbopack build: Skip webpack config tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Sep 5, 2024
1 parent 4f038db commit 21e9f20
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 94 deletions.
43 changes: 23 additions & 20 deletions test/integration/config-promise-error/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import { nextBuild } from 'next-test-utils'

const appDir = join(__dirname, '..')

describe('Promise in next config', () => {
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
afterEach(() => fs.remove(join(appDir, 'next.config.js')))
;(process.env.TURBOPACK ? describe.skip : describe)(
'Promise in next config',
() => {
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
afterEach(() => fs.remove(join(appDir, 'next.config.js')))

it('should warn when a promise is returned on webpack', async () => {
fs.writeFile(
join(appDir, 'next.config.js'),
`
it('should warn when a promise is returned on webpack', async () => {
fs.writeFile(
join(appDir, 'next.config.js'),
`
module.exports = (phase, { isServer }) => {
return {
webpack: async (config) => {
Expand All @@ -24,16 +26,17 @@ describe('Promise in next config', () => {
}
}
`
)
)

const { stderr, stdout } = await nextBuild(appDir, undefined, {
stderr: true,
stdout: true,
const { stderr, stdout } = await nextBuild(appDir, undefined, {
stderr: true,
stdout: true,
})
expect(stderr + stdout).toMatch(
/> Promise returned in next config\. https:\/\//
)
})
expect(stderr + stdout).toMatch(
/> Promise returned in next config\. https:\/\//
)
})
}
)
})
}
)
}
)
145 changes: 75 additions & 70 deletions test/integration/turbotrace-with-webpack-worker/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,77 +6,82 @@ import { nextBuild } from 'next-test-utils'

const appDir = join(__dirname, '../app')

describe('build trace with extra entries', () => {
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
it('should build and trace correctly', async () => {
const result = await nextBuild(appDir, undefined, {
cwd: appDir,
stderr: true,
stdout: true,
})
console.log(result)
expect(result.code).toBe(0)

const appTrace = await fs.readJSON(
join(appDir, '.next/server/pages/_app.js.nft.json')
)
const indexTrace = await fs.readJSON(
join(appDir, '.next/server/pages/index.js.nft.json')
)
const anotherTrace = await fs.readJSON(
join(appDir, '.next/server/pages/another.js.nft.json')
)
const imageTrace = await fs.readJSON(
join(appDir, '.next/server/pages/image-import.js.nft.json')
)

const tracedFiles = [
...appTrace.files,
...indexTrace.files,
...anotherTrace.files,
...imageTrace.files,
]
;(process.env.TURBOPACK ? describe.skip : describe)(
'build trace with extra entries',
() => {
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
it('should build and trace correctly', async () => {
const result = await nextBuild(appDir, undefined, {
cwd: appDir,
stderr: true,
stdout: true,
})
console.log(result)
expect(result.code).toBe(0)

expect(tracedFiles.some((file) => file.endsWith('hello.json'))).toBe(
true
)
expect(
tracedFiles.some((file) => file.includes('some-cms/index.js'))
).toBe(true)
expect(
tracedFiles.some((file) => file === '../../../include-me/hello.txt')
).toBe(true)
expect(
tracedFiles.some((file) => file === '../../../include-me/second.txt')
).toBe(true)
expect(
indexTrace.files.some((file) => file.includes('exclude-me'))
).toBe(false)

expect(
tracedFiles.some((file) =>
file.includes('nested-structure/constants/package.json')
const appTrace = await fs.readJSON(
join(appDir, '.next/server/pages/_app.js.nft.json')
)
const indexTrace = await fs.readJSON(
join(appDir, '.next/server/pages/index.js.nft.json')
)
).toBe(true)
expect(
tracedFiles.some((file) =>
file.includes('nested-structure/package.json')
const anotherTrace = await fs.readJSON(
join(appDir, '.next/server/pages/another.js.nft.json')
)
).toBe(true)
expect(
tracedFiles.some((file) =>
file.includes('nested-structure/lib/constants.js')
const imageTrace = await fs.readJSON(
join(appDir, '.next/server/pages/image-import.js.nft.json')
)
).toBe(true)
expect(
tracedFiles.some((file) => file.includes('public/another.jpg'))
).toBe(true)
expect(
tracedFiles.some((file) => file.includes('public/test.jpg'))
).toBe(false)
})
}
)
})

const tracedFiles = [
...appTrace.files,
...indexTrace.files,
...anotherTrace.files,
...imageTrace.files,
]

expect(tracedFiles.some((file) => file.endsWith('hello.json'))).toBe(
true
)
expect(
tracedFiles.some((file) => file.includes('some-cms/index.js'))
).toBe(true)
expect(
tracedFiles.some((file) => file === '../../../include-me/hello.txt')
).toBe(true)
expect(
tracedFiles.some(
(file) => file === '../../../include-me/second.txt'
)
).toBe(true)
expect(
indexTrace.files.some((file) => file.includes('exclude-me'))
).toBe(false)

expect(
tracedFiles.some((file) =>
file.includes('nested-structure/constants/package.json')
)
).toBe(true)
expect(
tracedFiles.some((file) =>
file.includes('nested-structure/package.json')
)
).toBe(true)
expect(
tracedFiles.some((file) =>
file.includes('nested-structure/lib/constants.js')
)
).toBe(true)
expect(
tracedFiles.some((file) => file.includes('public/another.jpg'))
).toBe(true)
expect(
tracedFiles.some((file) => file.includes('public/test.jpg'))
).toBe(false)
})
}
)
}
)
8 changes: 4 additions & 4 deletions test/turbopack-build-tests-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7555,10 +7555,10 @@
},
"test/integration/config-promise-error/test/index.test.js": {
"passed": [],
"failed": [
"failed": [],
"pending": [
"Promise in next config production mode should warn when a promise is returned on webpack"
],
"pending": [],
"flakey": [],
"runtimeError": false
},
Expand Down Expand Up @@ -15300,10 +15300,10 @@
},
"test/integration/turbotrace-with-webpack-worker/test/index.test.js": {
"passed": [],
"failed": [
"failed": [],
"pending": [
"build trace with extra entries production mode should build and trace correctly"
],
"pending": [],
"flakey": [],
"runtimeError": false
},
Expand Down

0 comments on commit 21e9f20

Please sign in to comment.