Skip to content

Commit

Permalink
test(dev): enable turbo tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Nov 15, 2022
1 parent a18ed6d commit 0e4a87f
Show file tree
Hide file tree
Showing 41 changed files with 771 additions and 200 deletions.
13 changes: 12 additions & 1 deletion test/development/acceptance-app/ReactRefresh.test.ts
Expand Up @@ -3,8 +3,18 @@ import { sandbox } from './helpers'
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import path from 'path'
import { shouldRunTurboDevTest } from 'next-test-utils'

const shouldRunTurboDev = shouldRunTurboDevTest()

describe.each([
['dev', false],
['turbo', true],
])('ReactRefresh app %s', (_name, turbo) => {
if (!!turbo && !shouldRunTurboDev) {
return
}

describe('ReactRefresh app', () => {
if (process.env.NEXT_TEST_REACT_VERSION === '^17') {
it('should skip for react v17', () => {})
return
Expand All @@ -14,6 +24,7 @@ describe('ReactRefresh app', () => {

beforeAll(async () => {
next = await createNext({
turbo: !!turbo,
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
dependencies: {
react: 'latest',
Expand Down
Expand Up @@ -2,9 +2,19 @@ import { sandbox } from './helpers'
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import path from 'path'
import { shouldRunTurboDevTest } from 'next-test-utils'

const shouldRunTurboDev = shouldRunTurboDevTest()

// TODO-APP: Investigate snapshot mismatch
describe('ReactRefreshLogBox app', () => {
describe.each([
['dev', false],
['turbo', true],
])('ReactRefreshLogBox app %s', (_name, turbo) => {
if (!!turbo && !shouldRunTurboDev) {
return
}

if (process.env.NEXT_TEST_REACT_VERSION === '^17') {
it('should skip for react v17', () => {})
return
Expand All @@ -14,6 +24,7 @@ describe('ReactRefreshLogBox app', () => {

beforeAll(async () => {
next = await createNext({
turbo: !!turbo,
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
dependencies: {
react: 'latest',
Expand Down
14 changes: 12 additions & 2 deletions test/development/acceptance-app/ReactRefreshLogBox.test.ts
Expand Up @@ -2,10 +2,19 @@
import { sandbox } from './helpers'
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { check } from 'next-test-utils'
import { check, shouldRunTurboDevTest } from 'next-test-utils'
import path from 'path'

describe('ReactRefreshLogBox app', () => {
const shouldRunTurboDev = shouldRunTurboDevTest()

describe.each([
['dev', false],
['turbo', true],
])('ReactRefreshLogBox app %s', (_name, turbo) => {
if (!!turbo && !shouldRunTurboDev) {
return
}

if (process.env.NEXT_TEST_REACT_VERSION === '^17') {
it('should skip for react v17', () => {})
return
Expand All @@ -15,6 +24,7 @@ describe('ReactRefreshLogBox app', () => {

beforeAll(async () => {
next = await createNext({
turbo: !!turbo,
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
dependencies: {
react: 'latest',
Expand Down
13 changes: 12 additions & 1 deletion test/development/acceptance-app/ReactRefreshModule.test.ts
Expand Up @@ -2,8 +2,18 @@ import { createNext, FileRef } from 'e2e-utils'
import path from 'path'
import { NextInstance } from 'test/lib/next-modes/base'
import { sandbox } from './helpers'
import { shouldRunTurboDevTest } from 'next-test-utils'

const shouldRunTurboDev = shouldRunTurboDevTest()

describe.each([
['dev', false],
['turbo', true],
])('ReactRefreshModule app %s', (_name, turbo) => {
if (!!turbo && !shouldRunTurboDev) {
return
}

describe('ReactRefreshModule app', () => {
if (process.env.NEXT_TEST_REACT_VERSION === '^17') {
it('should skip for react v17', () => {})
return
Expand All @@ -13,6 +23,7 @@ describe('ReactRefreshModule app', () => {

beforeAll(async () => {
next = await createNext({
turbo: !!turbo,
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
dependencies: {
react: 'latest',
Expand Down
13 changes: 12 additions & 1 deletion test/development/acceptance-app/ReactRefreshRegression.test.ts
Expand Up @@ -3,8 +3,18 @@ import { sandbox } from './helpers'
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import path from 'path'
import { shouldRunTurboDevTest } from 'next-test-utils'

const shouldRunTurboDev = shouldRunTurboDevTest()

describe.each([
['dev', false],
['turbo', true],
])('ReactRefreshRegression app %s', (_name, turbo) => {
if (!!turbo && !shouldRunTurboDev) {
return
}

describe('ReactRefreshRegression app', () => {
if (process.env.NEXT_TEST_REACT_VERSION === '^17') {
it('should skip for react v17', () => {})
return
Expand All @@ -14,6 +24,7 @@ describe('ReactRefreshRegression app', () => {

beforeAll(async () => {
next = await createNext({
turbo: !!turbo,
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
skipStart: true,
dependencies: {
Expand Down
13 changes: 12 additions & 1 deletion test/development/acceptance-app/ReactRefreshRequire.test.ts
Expand Up @@ -3,12 +3,23 @@ import { sandbox } from './helpers'
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import path from 'path'
import { shouldRunTurboDevTest } from 'next-test-utils'

const shouldRunTurboDev = shouldRunTurboDevTest()

describe.each([
['dev', false],
['turbo', true],
])('ReactRefreshRequire app %s', (_name, turbo) => {
if (!!turbo && !shouldRunTurboDev) {
return
}

describe('ReactRefreshRequire app', () => {
let next: NextInstance

beforeAll(async () => {
next = await createNext({
turbo: !!turbo,
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
dependencies: {
react: 'latest',
Expand Down
13 changes: 12 additions & 1 deletion test/development/acceptance/ReactRefresh.test.ts
Expand Up @@ -2,12 +2,23 @@
import { sandbox } from './helpers'
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { shouldRunTurboDevTest } from 'next-test-utils'

const shouldRunTurboDev = shouldRunTurboDevTest()

describe.each([
['dev', false],
['turbo', true],
])('ReactRefresh %s', (_name, turbo) => {
if (!!turbo && !shouldRunTurboDev) {
return
}

describe('ReactRefresh', () => {
let next: NextInstance

beforeAll(async () => {
next = await createNext({
turbo: !!turbo,
files: {},
skipStart: true,
})
Expand Down
29 changes: 24 additions & 5 deletions test/development/acceptance/ReactRefreshLogBox-app-doc.test.ts
@@ -1,12 +1,23 @@
import { sandbox } from './helpers'
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { shouldRunTurboDevTest } from 'next-test-utils'

const shouldRunTurboDev = shouldRunTurboDevTest()

describe.each([
['dev', false],
['turbo', true],
])('ReactRefreshLogBox %s', (_name, turbo) => {
if (!!turbo && !shouldRunTurboDev) {
return
}

describe('ReactRefreshLogBox', () => {
let next: NextInstance

beforeAll(async () => {
next = await createNext({
turbo: !!turbo,
files: {},
skipStart: true,
})
Expand All @@ -20,7 +31,7 @@ describe('ReactRefreshLogBox', () => {
[
'pages/_app.js',
`
`,
],
])
Expand Down Expand Up @@ -50,7 +61,7 @@ describe('ReactRefreshLogBox', () => {
[
'pages/_document.js',
`
`,
],
])
Expand Down Expand Up @@ -107,7 +118,11 @@ describe('ReactRefreshLogBox', () => {
])
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource()).toMatchSnapshot()
if (!turbo) {
expect(await session.getRedboxSource()).toMatchSnapshot()
} else {
expect(await session.getRedboxSource()).toMatchInlineSnapshot()
}

await session.patch(
'pages/_app.js',
Expand Down Expand Up @@ -156,7 +171,11 @@ describe('ReactRefreshLogBox', () => {
])
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource()).toMatchSnapshot()
if (!turbo) {
expect(await session.getRedboxSource()).toMatchSnapshot()
} else {
expect(await session.getRedboxSource()).toMatchInlineSnapshot()
}

await session.patch(
'pages/_document.js',
Expand Down
39 changes: 33 additions & 6 deletions test/development/acceptance/ReactRefreshLogBox-builtins.test.ts
@@ -1,12 +1,23 @@
import { sandbox } from './helpers'
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { shouldRunTurboDevTest } from 'next-test-utils'

const shouldRunTurboDev = shouldRunTurboDevTest()

describe.each([
['dev', false],
['turbo', true],
])('ReactRefreshLogBox %s', (_name, turbo) => {
if (!!turbo && !shouldRunTurboDev) {
return
}

describe('ReactRefreshLogBox', () => {
let next: NextInstance

beforeAll(async () => {
next = await createNext({
turbo: !!turbo,
files: {},
skipStart: true,
})
Expand Down Expand Up @@ -48,7 +59,11 @@ describe('ReactRefreshLogBox', () => {
`
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource()).toMatchSnapshot()
if (!turbo) {
expect(await session.getRedboxSource()).toMatchSnapshot()
} else {
expect(await session.getRedboxSource()).toMatchInlineSnapshot()
}

await cleanup()
})
Expand All @@ -72,7 +87,11 @@ describe('ReactRefreshLogBox', () => {
expect(await session.hasRedbox(true)).toBe(true)

const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
if (!turbo) {
expect(source).toMatchSnapshot()
} else {
expect(source).toMatchInlineSnapshot()
}

await cleanup()
})
Expand All @@ -96,7 +115,11 @@ describe('ReactRefreshLogBox', () => {
expect(await session.hasRedbox(true)).toBe(true)

const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
if (!turbo) {
expect(source).toMatchSnapshot()
} else {
expect(source).toMatchInlineSnapshot()
}

await cleanup()
})
Expand All @@ -109,7 +132,7 @@ describe('ReactRefreshLogBox', () => {
'pages/_app.js',
`
import './non-existent.css'
export default function App({ Component, pageProps }) {
return <Component {...pageProps} />
}
Expand All @@ -128,7 +151,11 @@ describe('ReactRefreshLogBox', () => {
expect(await session.hasRedbox(true)).toBe(true)

const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
if (!turbo) {
expect(source).toMatchSnapshot()
} else {
expect(source).toMatchInlineSnapshot()
}

await session.patch(
'pages/_app.js',
Expand Down

0 comments on commit 0e4a87f

Please sign in to comment.