
Product
Introducing GitHub Actions Scanning Support
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
Promisified jsdom setup and teardown for your test runner.
Inspired from, and wraps, jsdom-global. Depends on jsdom.
yarn add -D jazzdom jsdom jsdom-global
Option 1: Setting up and tearing down for tests that need a document object
import jazzdom from 'jazzdom'
describe('some tests', () => {
before(() => jazzdom.create())
after(() => jazzdom.destroy())
// ... test content here
}
Option 2: Global setup line for test/mocha.opts
Don't do this if you plan to use the other setup option.
--require jazzdom/register
In your mocha tests:
import React from 'react'
import { mount, shallow } from 'enzyme'
import jazzdom from 'jazzdom'
describe('Example', () => {
const Parent = ({ children }) => <div className="parent">{children}</div>
describe('without jazzdom integration', () => {
it('shallow renders without need of jsdom', () => {
const wrapper = shallow(
<Parent><div className="child" /></Parent>
)
expect(wrapper.find('div.child')).to.exist
})
})
describe('with basic integration', () => {
before(() => jazzdom.create())
after(() => jazzdom.destroy())
it('mounts with the help of jsdom', () => {
const wrapper = mount(
<Parent><div className="child" /></Parent>
)
expect(wrapper.find('div.child')).to.exist
})
})
require ('jazzdom/register')
only once across your entire test suite, since that may result in speed improvements.jazzdom.create()
, or other expensive tasks, and "fast" tests would not. Name them with slightly different patterns, and have two different test rules in package.json
to call each suite. Prefer to have more fast tests and less slow tests. Instead of making multiple slow tests, consider making one slow test and spies for the remaining tests, if that makes sense for the situation.jazzdom.create()
and jazzdom.destroy()
only when they're needed, such as with enzyme.mount()
, and omit them with enzyme.shallow()
and enzyme.render()
.jazzdom.create()
and jazzdom.destroy()
in a beforeEach()
or afterEach()
block. Prefer before()
and after()
blocks, or in dedicated it()
blocks if your test runner doesn't support before
/after
.create()
and destroy()
functionsconsole
output from <script>
tags into the standard node.js console
objectcreated
event to be fired before fulfilling or rejecting promisedestroy()
the previous setup, the next create()
call will throw an error that points to the previous invocationMIT
FAQs
Promisified jsdom setup and teardown for your test runner.
We found that jazzdom demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.