fake browser runtime environment in server-side render.
npm install ssr-polyfill> fake browser runtime environment in server-side render.
``sh`
npm install ssr-polyfill --saveor yarn add ssr-polyfill
`jswindow.document
const ssrPolyfill = require('ssr-polyfill');
global.window = ssrPolyfill({
context: {
userInfo: 'hello',
}
});
global.self = global.window;
// maybe you can mock somewhere
// not use use document.*window.context
global.document = global.window.document;
// in client env is { userInfo: 'hello' }`
- url default is http://localhost, you also change the location.pathname use http://localhost/barhtml
- init html template, default is
- other params will mount in window objectRun tests
`sh
npm run test
``* Github: @ycjcl868
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a ⭐️ if this project helped you!
This project is ISC licensed.