Unverified Commit db2c7bf7 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Enable more tests for Turbopack (#83589)

parent 928c4db7
...@@ -6,7 +6,7 @@ import { join } from 'path' ...@@ -6,7 +6,7 @@ import { join } from 'path'
// In order for the global isNextStart to be set // In order for the global isNextStart to be set
import 'e2e-utils' import 'e2e-utils'
// TODO: Implement warning for Turbopack // Importing module CSS in _document is allowed in Turbopack
;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)( ;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)(
'Invalid SCSS in _document', 'Invalid SCSS in _document',
() => { () => {
......
...@@ -13,7 +13,7 @@ import { join } from 'path' ...@@ -13,7 +13,7 @@ import { join } from 'path'
const fixturesDir = join(__dirname, '../..', 'css-fixtures') const fixturesDir = join(__dirname, '../..', 'css-fixtures')
// TODO: Implement warning for Turbopack // Importing module CSS in _document is allowed in Turbopack
;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)( ;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)(
'Invalid CSS in _document', 'Invalid CSS in _document',
() => { () => {
...@@ -45,38 +45,36 @@ const fixturesDir = join(__dirname, '../..', 'css-fixtures') ...@@ -45,38 +45,36 @@ const fixturesDir = join(__dirname, '../..', 'css-fixtures')
) )
} }
) )
;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)(
'Invalid Global CSS',
() => {
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
const appDir = join(fixturesDir, 'invalid-global')
beforeAll(async () => { describe('Invalid Global CSS', () => {
await remove(join(appDir, '.next')) ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
}) 'production mode',
() => {
const appDir = join(fixturesDir, 'invalid-global')
// eslint-disable-next-line jest/no-identical-title beforeAll(async () => {
it('should fail to build', async () => { await remove(join(appDir, '.next'))
const { code, stderr } = await nextBuild(appDir, [], { })
stderr: true,
}) // eslint-disable-next-line jest/no-identical-title
expect(code).not.toBe(0) it('should fail to build', async () => {
expect(stderr).toContain('Failed to compile') const { code, stderr } = await nextBuild(appDir, [], {
expect(stderr).toContain('styles/global.css') stderr: true,
expect(stderr).toMatch(
/Please move all first-party global CSS imports.*?pages(\/|\\)_app/
)
// Skip: Rspack loaders cannot access module issuer info for location details
if (!process.env.NEXT_RSPACK) {
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}
}) })
} expect(code).not.toBe(0)
) expect(stderr).toContain('Failed to compile')
} expect(stderr).toContain('styles/global.css')
) expect(stderr).toMatch(
/Please move all first-party global CSS imports.*?pages(\/|\\)_app/
)
// Skip: Rspack loaders cannot access module issuer info for location details
if (!process.env.NEXT_RSPACK) {
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}
})
}
)
})
describe('Valid Global CSS from npm', () => { describe('Valid Global CSS from npm', () => {
;(process.env.TURBOPACK_DEV ? describe.skip : describe)( ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
...@@ -114,80 +112,68 @@ describe('Valid Global CSS from npm', () => { ...@@ -114,80 +112,68 @@ describe('Valid Global CSS from npm', () => {
.replace(/\/\*.*?\*\//g, '') .replace(/\/\*.*?\*\//g, '')
.trim() .trim()
if (process.env.IS_TURBOPACK_TEST) { expect(cssContent).toMatchInlineSnapshot(`".red-text{color:"red"}"`)
expect(cssContent).toMatchInlineSnapshot(`".red-text{color:"red"}"`)
} else {
expect(cssContent).toMatchInlineSnapshot(`".red-text{color:"red"}"`)
}
}) })
} }
) )
}) })
// TODO: Implement warning for Turbopack describe('Invalid Global CSS with Custom App', () => {
;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)( ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'Invalid Global CSS with Custom App', 'production mode',
() => { () => {
;(process.env.TURBOPACK_DEV ? describe.skip : describe)( const appDir = join(fixturesDir, 'invalid-global-with-app')
'production mode',
() => {
const appDir = join(fixturesDir, 'invalid-global-with-app')
beforeAll(async () => { beforeAll(async () => {
await remove(join(appDir, '.next')) await remove(join(appDir, '.next'))
}) })
// eslint-disable-next-line jest/no-identical-title // eslint-disable-next-line jest/no-identical-title
it('should fail to build', async () => { it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], { const { code, stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
})
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles/global.css')
expect(stderr).toMatch(
/Please move all first-party global CSS imports.*?pages(\/|\\)_app/
)
// Skip: Rspack loaders cannot access module issuer info for location details
if (!process.env.NEXT_RSPACK) {
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}
}) })
} expect(code).not.toBe(0)
) expect(stderr).toContain('Failed to compile')
} expect(stderr).toContain('styles/global.css')
) expect(stderr).toMatch(
/Please move all first-party global CSS imports.*?pages(\/|\\)_app/
)
// Skip: Rspack loaders cannot access module issuer info for location details
if (!process.env.NEXT_RSPACK) {
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}
})
}
)
})
// TODO: Implement warning for Turbopack describe('Valid and Invalid Global CSS with Custom App', () => {
;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)( ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'Valid and Invalid Global CSS with Custom App', 'production mode',
() => { () => {
;(process.env.TURBOPACK_DEV ? describe.skip : describe)( const appDir = join(fixturesDir, 'valid-and-invalid-global')
'production mode',
() => {
const appDir = join(fixturesDir, 'valid-and-invalid-global')
beforeAll(async () => { beforeAll(async () => {
await remove(join(appDir, '.next')) await remove(join(appDir, '.next'))
}) })
// eslint-disable-next-line jest/no-identical-title // eslint-disable-next-line jest/no-identical-title
it('should fail to build', async () => { it('should fail to build', async () => {
const { code, stderr } = await nextBuild(appDir, [], { const { code, stderr } = await nextBuild(appDir, [], {
stderr: true, stderr: true,
})
expect(code).not.toBe(0)
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles/global.css')
expect(stderr).toContain(
'Please move all first-party global CSS imports'
)
// Skip: Rspack loaders cannot access module issuer info for location details
if (!process.env.NEXT_RSPACK) {
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}
}) })
} expect(code).not.toBe(0)
) expect(stderr).toContain('Failed to compile')
} expect(stderr).toContain('styles/global.css')
) expect(stderr).toContain(
'Please move all first-party global CSS imports'
)
// Skip: Rspack loaders cannot access module issuer info for location details
if (!process.env.NEXT_RSPACK) {
expect(stderr).toMatch(/Location:.*pages[\\/]index\.js/)
}
})
}
)
})
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