Skip to content

bahmutov/hyperapp-es6-module-cypress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hyperapp-es6-module-cypress

Testing Hyperapp with ES6 module import in Cypress example

Read blog post

If your application uses <script type="module"> and you pick Electron browser in Cypress end-to-end test runner, the app won't run. This example shows how to add ES6 module support to the Electron browser from your tests.

Example: mini app importing Hyperapp framework as a module

images/hyperapp-import.png

The test spec.js loads modules from dist folder that add ES6 support

const addScript = (document, src) => {
  // force immediate load
  document.write(`<script src="${src}"></script>`)
}
// load es6 module bundler from
// https://github.com/ModuleLoader/browser-es-module-loader
// we built the "dist" folder ourselves
beforeEach(() => {
  cy.visit('index.html', {
    onBeforeLoad: win => {
      addScript(win.document, 'dist/babel-browser-build.js') // must be first
      addScript(win.document, 'dist/browser-es-module-loader.js')
    },
  })
})
// tests

And now the tests run in Electron browser

Electron is running tests

About

Testing Hyperapp with ES6 module import in Cypress example

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published