Skip to content

Commit ded63ad

Browse files
feat(app): remove __vite__ route and default to unified runner (#18909)
Co-authored-by: Mark Noonan <mark@cypress.io>
1 parent cdc8c42 commit ded63ad

File tree

5 files changed

+34
-18
lines changed

5 files changed

+34
-18
lines changed

packages/app/cypress/e2e/integration/navigation.spec.ts

-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,5 @@ describe('Navigation', () => {
1313
cy.wait('@OpenExternal').then((interception: Interception) => {
1414
expect(interception.request.body.variables.url).to.equal('https://on.cypress.io/writing-first-test?utm_medium=Docs+Menu&utm_content=First+Test')
1515
})
16-
17-
cy.get('[href="#/runs"]').click()
18-
cy.contains(defaultMessages.runs.connect.title).should('be.visible')
1916
})
2017
})

packages/data-context/src/sources/HtmlDataSource.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class HtmlDataSource {
3030
return html
3131
}
3232

33-
return this.ctx.fs.readFile(getPathToDist('app'), 'utf8')
33+
return this.ctx.fs.readFile(getPathToDist('app', 'index.html'), 'utf8')
3434
}
3535

3636
/**

packages/driver/cypress.config.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { defineConfig } from 'cypress'
22

33
export default defineConfig({
44
'projectId': 'ypt4pf',
5-
'baseUrl': 'http://localhost:3500',
5+
'e2e': {
6+
'baseUrl': 'http://localhost:3500',
7+
},
68
'testFiles': '**/*',
79
'hosts': {
810
'*.foobar.com': '127.0.0.1',

packages/server/lib/project_utils.ts

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ const multipleForwardSlashesRe = /[^:\/\/](\/{2,})/g
1313
const backSlashesRe = /\\/g
1414

1515
const normalizeSpecUrl = (browserUrl: string, specUrl: string) => {
16+
if (process.env.LAUNCHPAD) {
17+
return browserUrl
18+
}
19+
1620
const replacer = (match: string) => match.replace('//', '/')
1721

1822
return [

packages/server/lib/routes.ts

+26-13
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ export const createCommonRoutes = ({
9494
target: `http://localhost:${process.env.CYPRESS_INTERNAL_VITE_APP_PORT}/`,
9595
})
9696

97-
router.get('/__vite__/', (req, res) => {
98-
ctx.html.appHtml().then((html) => res.send(html)).catch((e) => res.status(500).send({ stack: e.stack }))
99-
})
100-
10197
// TODO: can namespace this onto a "unified" route like __app-unified__
10298
// make sure to update the generated routes inside of vite.config.ts
10399
router.get('/__vite__/*', (req, res) => {
@@ -146,15 +142,32 @@ export const createCommonRoutes = ({
146142
router.get(clientRoute, (req, res) => {
147143
debug('Serving Cypress front-end by requested URL:', req.url)
148144

149-
runner.serve(req, res, testingType === 'e2e' ? 'runner' : 'runner-ct', {
150-
config,
151-
testingType,
152-
getSpec,
153-
getCurrentBrowser,
154-
getRemoteState,
155-
specsStore,
156-
exit,
157-
})
145+
if (process.env.LAUNCHPAD) {
146+
ctx.html.appHtml()
147+
.then((html) => res.send(html))
148+
.catch((e) => res.status(500).send({ stack: e.stack }))
149+
} else {
150+
runner.serve(req, res, testingType === 'e2e' ? 'runner' : 'runner-ct', {
151+
config,
152+
testingType,
153+
getSpec,
154+
getCurrentBrowser,
155+
getRemoteState,
156+
specsStore,
157+
exit,
158+
})
159+
}
160+
})
161+
162+
// serve static assets from the dist'd Vite app
163+
router.get([
164+
`${clientRoute}assets/*`,
165+
`${clientRoute}shiki/*`,
166+
], (req, res) => {
167+
debug('proxying static assets %s, params[0] %s', req.url, req.params[0])
168+
const pathToFile = getPathToDist('app', 'assets', req.params[0])
169+
170+
return send(req, pathToFile).pipe(res)
158171
})
159172

160173
router.all('*', (req, res) => {

0 commit comments

Comments
 (0)