Mounting Helmet Tests not working in v5
See original GitHub issueRunning tests for document.head updates using enzyme’s mount
function for version 4 and all works fine. Started a migration to v5 but my mounted tests have stopped working.
Setup document:
import { jsdom } from 'jsdom'
import { keys } from 'ramda'
global.document = jsdom(
'<html><head></head><body><div id="application-root"></div></body></html>'
)
global.window = document.defaultView
keys(document.defaultView).forEach(property => {
if (typeof global[property] === 'undefined') {
global[property] = document.defaultView[property]
}
})
global.navigator = { userAgent: 'node.js' }
My main application render:
const Main = () =>
<DocumentMeta
defaultTitle='Breko Hub'
titleTemplate='%s | Breko Hub'>
<html lang='en' />
<meta charSet='utf-8' />
</DocumentMeta>
Running the tests
const wrapper = mount(Main, { attachTo: document.getElementById('application-root') })
setImmediate(() => {
// This works:
expect(document.title).to.eql('Breko Hub')
// This doesn't work anymore in v5, worked fine in v4
const meta = document.querySelector('meta')
// meta === null
})
I have server side tests ensuring that the server renders the appropriate attributes and they work fine using Helmet.canUseDOM = false
. But the client-side tests which actually assume the DOM is usable, aren’t working anymore. The document.head remains empty.
const wrapper = mount(Main, { attachTo: document.getElementById('application-root') })
setImmediate(() => {
(document.head || document.querySelector('head')).innerHTML
// returns an empty string
})
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top Results From Across the Web
49 CFR § 571.218 - Standard No. 218; Motorcycle helmets.
The helmet is fixed on the test headform as necessary to ensure that it does not move during the application of the test...
Read more >Effect of helmet design on impact performance of industrial ...
The study concluded that helmet testing standards should evaluate protection against fall-induced TBI as well as skull fractures from falling objects.
Read more >helmet - npm
First, run npm install helmet for your app. Then, in an Express app: const express = require("express"); const helmet = require("helmet"); ...
Read more >Amazon.com: Motorcycle Helmet Bluetooth Headset,Geva BT ...
Motorcycle Helmet Bluetooth Headset,Geva BT V5.0 Bluetooth for Helmet,160 Hrs Riding Bluetooth Speaker Helmet, A10 Motorbike Helmet Communication System ...
Read more >49 CFR 571.218 -- Standard No. 218; Motorcycle helmets.
Secure the helmet so that it does not shift position before impact or before application of force during testing.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can use our polyfill:
I looks like requestIdleCallback was replaces with requestAnimationFrame from v5.2.0
you will need to import it instead