|
1 | 1 | /// <reference path="../support/e2e.ts" />
|
2 | 2 | import type { ProjectFixtureDir } from '@tooling/system-tests/lib/fixtureDirs'
|
3 | 3 |
|
4 |
| -const WEBPACK_REACT: ProjectFixtureDir[] = ['next-12', 'next-12.1.6', 'next-13', 'next-13-tsconfig'] |
5 |
| - |
| 4 | +const WEBPACK_REACT: ProjectFixtureDir[] = ['next-12', 'next-12.1.6', 'next-13', 'next-13-tsconfig', 'next-14'] |
6 | 5 | // Add to this list to focus on a particular permutation
|
7 | 6 | const ONLY_PROJECTS: ProjectFixtureDir[] = []
|
8 | 7 |
|
@@ -106,3 +105,100 @@ for (const project of WEBPACK_REACT) {
|
106 | 105 | })
|
107 | 106 | })
|
108 | 107 | }
|
| 108 | + |
| 109 | +// Since next-14-tsconfig-tailwind does not use the fixture directory we need to write our own test suite |
| 110 | +// We want to specifically test typescript files with next-14 as there have been known problems with |
| 111 | +// module: bundler and cypress compatibility |
| 112 | +describe(`Working with next-14-tsconfig-tailwind`, () => { |
| 113 | + beforeEach(() => { |
| 114 | + cy.scaffoldProject('next-14-tsconfig-tailwind') |
| 115 | + cy.openProject('next-14-tsconfig-tailwind', ['--component']) |
| 116 | + cy.startAppServer('component') |
| 117 | + }) |
| 118 | + |
| 119 | + it('should mount a passing test', () => { |
| 120 | + cy.visitApp() |
| 121 | + cy.specsPageIsVisible() |
| 122 | + cy.contains('page.cy.tsx').click() |
| 123 | + cy.waitForSpecToFinish({ passCount: 1 }) |
| 124 | + }) |
| 125 | + |
| 126 | + it('should live-reload on src changes', () => { |
| 127 | + cy.visitApp() |
| 128 | + cy.specsPageIsVisible() |
| 129 | + |
| 130 | + cy.contains('page.cy.tsx').click() |
| 131 | + cy.waitForSpecToFinish({ passCount: 1 }) |
| 132 | + |
| 133 | + cy.withCtx(async (ctx) => { |
| 134 | + const indexPath = ctx.path.join('app', 'page.tsx') |
| 135 | + |
| 136 | + await ctx.actions.file.writeFileInProject( |
| 137 | + indexPath, |
| 138 | + (await ctx.file.readFileInProject(indexPath)).replace('Welcome to', 'Hello from'), |
| 139 | + ) |
| 140 | + }) |
| 141 | + |
| 142 | + cy.waitForSpecToFinish({ failCount: 1 }) |
| 143 | + cy.get('.test-err-code-frame').should('be.visible') |
| 144 | + |
| 145 | + cy.withCtx(async (ctx) => { |
| 146 | + const indexTestPath = ctx.path.join('app', 'page.cy.tsx') |
| 147 | + |
| 148 | + await ctx.actions.file.writeFileInProject( |
| 149 | + indexTestPath, |
| 150 | + (await ctx.file.readFileInProject(indexTestPath)).replace('Welcome to', 'Hello from'), |
| 151 | + ) |
| 152 | + }) |
| 153 | + |
| 154 | + cy.waitForSpecToFinish({ passCount: 1 }) |
| 155 | + }) |
| 156 | + |
| 157 | + it('should show compilation errors on src changes', () => { |
| 158 | + cy.visitApp() |
| 159 | + cy.specsPageIsVisible() |
| 160 | + |
| 161 | + cy.contains('page.cy.tsx').click() |
| 162 | + cy.waitForSpecToFinish({ passCount: 1 }) |
| 163 | + |
| 164 | + // Create compilation error |
| 165 | + cy.withCtx(async (ctx) => { |
| 166 | + const indexPath = ctx.path.join('app', 'page.tsx') |
| 167 | + |
| 168 | + await ctx.actions.file.writeFileInProject( |
| 169 | + indexPath, |
| 170 | + (await ctx.file.readFileInProject(indexPath)).replace('export', 'expart'), |
| 171 | + ) |
| 172 | + }) |
| 173 | + |
| 174 | + // The test should fail and the stack trace should appear in the command log |
| 175 | + cy.waitForSpecToFinish({ failCount: 1 }) |
| 176 | + cy.contains('The following error originated from your test code, not from Cypress.').should('exist') |
| 177 | + }) |
| 178 | + |
| 179 | + it('should detect new spec', { retries: 15 }, () => { |
| 180 | + cy.visitApp() |
| 181 | + cy.specsPageIsVisible() |
| 182 | + |
| 183 | + cy.withCtx(async (ctx) => { |
| 184 | + const newTestPath = ctx.path.join('app', 'New.cy.tsx') |
| 185 | + const indexTestPath = ctx.path.join('app', 'page.cy.tsx') |
| 186 | + |
| 187 | + await ctx.actions.file.writeFileInProject( |
| 188 | + newTestPath, |
| 189 | + await ctx.file.readFileInProject(indexTestPath), |
| 190 | + ) |
| 191 | + }) |
| 192 | + |
| 193 | + cy.contains('New.cy.tsx').click() |
| 194 | + cy.waitForSpecToFinish({ passCount: 1 }) |
| 195 | + }) |
| 196 | + |
| 197 | + // Make sure tailwind styles are appearing in the test. |
| 198 | + it('should allow import of global styles in support file', { retries: 15 }, () => { |
| 199 | + cy.visitApp() |
| 200 | + cy.specsPageIsVisible() |
| 201 | + cy.contains('page-styles.cy.tsx').click() |
| 202 | + cy.waitForSpecToFinish({ passCount: 1 }) |
| 203 | + }) |
| 204 | +}) |
0 commit comments