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