Merge pull request #16141 from cypress-io/b45fd0e8a-master-into-develop

This commit is contained in:
Barthélémy Ledoux
2021-04-22 10:40:28 -05:00
committed by GitHub
2 changed files with 11 additions and 4 deletions

View File

@@ -1343,6 +1343,7 @@ jobs:
- run:
name: Build
command: yarn workspace @cypress/mount-utils build
- store-npm-logs
npm-create-cypress-tests:
<<: *defaults

View File

@@ -1,4 +1,4 @@
import { resolve } from 'path'
import { resolve, sep } from 'path'
import { readFile } from 'fs'
import { promisify } from 'util'
import { Plugin, ViteDevServer } from 'vite'
@@ -7,7 +7,9 @@ const read = promisify(readFile)
const pluginName = 'cypress-transform-html'
const INIT_FILEPATH = resolve(__dirname, '../client/initCypressTests.js')
const OSSepRE = new RegExp(`\\${sep}`, 'g')
const INIT_FILEPATH = resolve(__dirname, '../client/initCypressTests.js').replace(OSSepRE, '/')
export const makeCypressPlugin = (
projectRoot: string,
@@ -16,6 +18,10 @@ export const makeCypressPlugin = (
): Plugin => {
let base = '/'
const posixSupportFilePath = supportFilePath ? resolve(projectRoot, supportFilePath).replace(OSSepRE, '/') : undefined
const normalizedSupportFilePath = posixSupportFilePath ? `${base}@fs/${posixSupportFilePath}` : undefined
return {
name: pluginName,
enforce: 'pre',
@@ -23,7 +29,7 @@ export const makeCypressPlugin = (
if (env) {
return {
define: {
'import.meta.env.__cypress_supportPath': JSON.stringify(supportFilePath ? resolve(projectRoot, supportFilePath) : undefined),
'import.meta.env.__cypress_supportPath': JSON.stringify(normalizedSupportFilePath),
'import.meta.env.__cypress_originAutUrl': JSON.stringify('__cypress/iframes/'),
},
}
@@ -40,7 +46,7 @@ export const makeCypressPlugin = (
tag: 'script',
injectTo: 'body',
attrs: { type: 'module' },
children: `import(${JSON.stringify(INIT_FILEPATH)})`,
children: `import(${JSON.stringify(`${base}@fs/${INIT_FILEPATH}`)})`,
},
]
},