Commit d84f2919 authored by Lukáš Huvar's avatar Lukáš Huvar Committed by Joe Haddad

Make tests for both async and sync GIP (#7999)

parent 0b496a45
......@@ -2,7 +2,7 @@ import { NextPageContext } from 'next'
import ErrorComponent from 'next/error'
class CustomError extends ErrorComponent {
static async getInitialProps({ res }: NextPageContext) {
static getInitialProps({ res }: NextPageContext) {
const statusCode = 500
return { statusCode, title: 'CustomError' }
}
......
/* eslint-env jest */
import { join } from 'path'
import cheerio from 'cheerio'
import { runNextCommand } from 'next-test-utils'
import { runNextCommand, File } from 'next-test-utils'
const appDir = join(__dirname, '../')
......@@ -17,7 +17,22 @@ export default (context, render) => {
expect($('body').text()).toMatch(/Hello World/)
})
it('Should compile the app', async () => {
it('should compile the app', async () => {
const output = await runNextCommand(['build', appDir], { stdout: true })
expect(output.stdout).toMatch(/Compiled successfully/)
})
})
describe('should compile with different types', () => {
const nextConfig = new File(join(appDir, 'pages/_error.tsx'))
beforeEach(() => {
nextConfig.replace('static ', 'static async ')
})
afterEach(() => {
nextConfig.restore()
})
it('should compile async getInitialProps for _error', async () => {
const output = await runNextCommand(['build', appDir], { stdout: true })
expect(output.stdout).toMatch(/Compiled successfully/)
})
......
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