Load-Frame
Utility for isomorphically loading an iframe with a URL. Makes it easy to bundle your tests in the browser while having a fast running CLI test with JSDOM.
It works by creating a regular iframe in the browser and using jsdom to create a fake iframe when running in node.
This is transparent and uses the package.json
's browser
field to provide the correct api. Simply build your tests with webpack, rollup or browserify and it should run in the browser.
Installation
npm install load-frame
Example (Using Mocha)
const assert = ;const load = ;
API
#fromURL(url: string) => Promise
Loads up an iframe like object from a url.
// Load from a server.load // Load from a file.const filePath = pathload
#fromString(html: string) => Promise
Loads up an iframe like object from a string of html.
const html = `<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>Example Title</title> </head> <body> Example Content </body></html>` // Load from html string.load
Contributions
- Use
npm test
to build and run tests.
Please feel free to create a PR!