mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-23 15:39:28 -05:00
71 lines
1.7 KiB
HTML
71 lines
1.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
<title>Components App</title>
|
|
<script>
|
|
function appendTargetIfNotExists(id, tag = 'div', parent = document.body) {
|
|
let node = document.getElementById(id)
|
|
|
|
if (!node) {
|
|
node = document.createElement(tag)
|
|
node.setAttribute('id', id)
|
|
parent.appendChild(node)
|
|
}
|
|
|
|
node.innerHTML = ''
|
|
|
|
return node
|
|
}
|
|
|
|
/**
|
|
* Format the requested spec file.
|
|
* Nollup writes everything to a single directory (eg /dist)
|
|
* All outputted files are *.js.
|
|
* RunnerCt requests specs using the original filename including extension.
|
|
*
|
|
* Example usage:
|
|
* formatSpecName('/cypress/component/foo.spec.tsx') //=> 'foo.spec.js'
|
|
*/
|
|
function formatSpecName (filename) {
|
|
const split = filename.split('/')
|
|
const name = split[split.length - 1]
|
|
const pos = name.lastIndexOf('.')
|
|
const newName = `${name.substr(0, pos < 0 ? name.length : pos)}.js`
|
|
|
|
return `/${newName}`
|
|
}
|
|
|
|
const Cypress = window.Cypress = parent.Cypress
|
|
|
|
const specPath = `/__cypress/src/${formatSpecName(window.location.pathname)}`
|
|
|
|
const importsToLoad = [
|
|
() => {
|
|
{{{supportFile}}}
|
|
},
|
|
() => import(specPath),
|
|
|
|
]
|
|
|
|
Cypress.onSpecWindow(window, importsToLoad)
|
|
Cypress.action('app:window:before:load', window)
|
|
|
|
beforeEach(() => {
|
|
const root = appendTargetIfNotExists('__cy_root')
|
|
|
|
root.appendChild(appendTargetIfNotExists('__cy_app'))
|
|
})
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
<div id="app"></div>
|
|
</body>
|
|
|
|
</html> |