Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check CSS Test Output #10237

Merged
merged 12 commits into from Jan 23, 2020
33 changes: 24 additions & 9 deletions test/integration/css-customization/test/index.test.js
Expand Up @@ -16,8 +16,12 @@ describe('CSS Customization', () => {
await remove(join(appDir, '.next'))
})

it('should build successfully', async () => {
await nextBuild(appDir)
it('should compile successfully', async () => {
const { code, stdout } = await nextBuild(appDir, [], {
stdout: true,
})
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
})

it(`should've compiled and prefixed`, async () => {
Expand Down Expand Up @@ -78,8 +82,12 @@ describe('Legacy Next-CSS Customization', () => {
await remove(join(appDir, '.next'))
})

it('should build successfully', async () => {
await nextBuild(appDir)
it('should compile successfully', async () => {
const { code, stdout } = await nextBuild(appDir, [], {
stdout: true,
})
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
})

it(`should've compiled and prefixed`, async () => {
Expand All @@ -103,8 +111,12 @@ describe('CSS Customization Array', () => {
await remove(join(appDir, '.next'))
})

it('should build successfully', async () => {
await nextBuild(appDir)
it('should compile successfully', async () => {
const { code, stdout } = await nextBuild(appDir, [], {
stdout: true,
})
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
})

it(`should've compiled and prefixed`, async () => {
Expand Down Expand Up @@ -168,9 +180,12 @@ describe('Bad CSS Customization', () => {
await remove(join(appDir, '.next'))
})

it('should build successfully', async () => {
const { stderr } = await nextBuild(appDir, [], { stderr: true })

it('should compile successfully', async () => {
const { stdout, stderr } = await nextBuild(appDir, [], {
stdout: true,
stderr: true,
})
expect(stdout).toMatch(/Compiled successfully/)
expect(stderr).toMatch(/field which is not supported.*?sourceMap/)
;[
'postcss-modules-values',
Expand Down
45 changes: 40 additions & 5 deletions test/integration/css-features/test/index.test.js
Expand Up @@ -11,9 +11,16 @@ const fixturesDir = join(__dirname, '../fixtures')
describe('Browserslist: Old', () => {
const appDir = join(fixturesDir, 'browsers-old')

let stdout
beforeAll(async () => {
await remove(join(appDir, '.next'))
await nextBuild(appDir)
;({ stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})

it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/)
})

it(`should've emitted a single CSS file`, async () => {
Expand All @@ -34,9 +41,16 @@ describe('Browserslist: Old', () => {
describe('Browserslist: New', () => {
const appDir = join(fixturesDir, 'browsers-new')

let stdout
beforeAll(async () => {
await remove(join(appDir, '.next'))
await nextBuild(appDir)
;({ stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})

it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/)
})

it(`should've emitted a single CSS file`, async () => {
Expand All @@ -57,9 +71,16 @@ describe('Browserslist: New', () => {
describe('Custom Properties: Pass-Through IE11', () => {
const appDir = join(fixturesDir, 'cp-ie-11')

let stdout
beforeAll(async () => {
await remove(join(appDir, '.next'))
await nextBuild(appDir)
;({ stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})

it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/)
})

it(`should've emitted a single CSS file`, async () => {
Expand All @@ -80,9 +101,16 @@ describe('Custom Properties: Pass-Through IE11', () => {
describe('Custom Properties: Pass-Through Modern', () => {
const appDir = join(fixturesDir, 'cp-modern')

let stdout
beforeAll(async () => {
await remove(join(appDir, '.next'))
await nextBuild(appDir)
;({ stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})

it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/)
})

it(`should've emitted a single CSS file`, async () => {
Expand Down Expand Up @@ -137,9 +165,16 @@ describe('Custom Properties: Fail for global element in CSS Modules', () => {
describe('CSS Modules: Import Global CSS', () => {
const appDir = join(fixturesDir, 'module-import-global')

let stdout
beforeAll(async () => {
await remove(join(appDir, '.next'))
await nextBuild(appDir)
;({ stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})

it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/)
})

it(`should've emitted a single CSS file`, async () => {
Expand Down
65 changes: 58 additions & 7 deletions test/integration/css-modules/test/index.test.js
Expand Up @@ -23,16 +23,23 @@ describe('Basic CSS Module Support', () => {

let appPort
let app
let stdout
beforeAll(async () => {
await remove(join(appDir, '.next'))
await nextBuild(appDir)
;({ stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
})

it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/)
})

it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css')

Expand Down Expand Up @@ -70,16 +77,23 @@ describe('3rd Party CSS Module Support', () => {

let appPort
let app
let stdout
beforeAll(async () => {
await remove(join(appDir, '.next'))
await nextBuild(appDir)
;({ stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
})

it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/)
})

it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css')

Expand Down Expand Up @@ -141,16 +155,23 @@ describe('Has CSS Module in computed styles in Production', () => {

let appPort
let app
let stdout
beforeAll(async () => {
await remove(join(appDir, '.next'))
await nextBuild(appDir)
;({ stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
})

it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/)
})

it('should have CSS for page', async () => {
const browser = await webdriver(appPort, '/')

Expand Down Expand Up @@ -257,15 +278,23 @@ describe('Valid CSS Module Usage from within node_modules', () => {

let appPort
let app
let stdout
beforeAll(async () => {
await nextBuild(appDir)
await remove(join(appDir, '.next'))
;({ stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
})

it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/)
})

it(`should've prerendered with relevant data`, async () => {
const content = await renderViaHTTP(appPort, '/')
const $ = cheerio.load(content)
Expand Down Expand Up @@ -300,15 +329,23 @@ describe('Valid Nested CSS Module Usage from within node_modules', () => {

let appPort
let app
let stdout
beforeAll(async () => {
await nextBuild(appDir)
await remove(join(appDir, '.next'))
;({ stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
})

it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/)
})

it(`should've prerendered with relevant data`, async () => {
const content = await renderViaHTTP(appPort, '/')
const $ = cheerio.load(content)
Expand Down Expand Up @@ -338,9 +375,16 @@ describe('CSS Module Composes Usage (Basic)', () => {
// This is a very bad feature. Do not use it.
const appDir = join(fixturesDir, 'composes-basic')

let stdout
beforeAll(async () => {
await remove(join(appDir, '.next'))
await nextBuild(appDir)
;({ stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})

it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/)
})

it(`should've emitted a single CSS file`, async () => {
Expand All @@ -362,9 +406,16 @@ describe('CSS Module Composes Usage (External)', () => {
// This is a very bad feature. Do not use it.
const appDir = join(fixturesDir, 'composes-external')

let stdout
beforeAll(async () => {
await remove(join(appDir, '.next'))
await nextBuild(appDir)
;({ stdout } = await nextBuild(appDir, [], {
stdout: true,
}))
})

it('should have compiled successfully', () => {
expect(stdout).toMatch(/Compiled successfully/)
})

it(`should've emitted a single CSS file`, async () => {
Expand Down