Installations
npm install @happy-dom/jest-environment
Developer Guide
Typescript
Yes
Module System
CommonJS
Min. Node Version
>=18.0.0
Node Version
22.12.0
NPM Version
10.9.0
Releases
Contributors
Languages
TypeScript (99.37%)
JavaScript (0.63%)
Developer
capricorn86
Download Statistics
Total Downloads
2,447,413
Last Day
2,239
Last Week
18,206
Last Month
146,358
Last Year
1,615,634
GitHub Statistics
3,492 Stars
2,120 Commits
210 Forks
13 Watching
3 Branches
124 Contributors
Package Meta Information
Latest Version
16.3.0
Package Id
@happy-dom/jest-environment@16.3.0
Unpacked Size
30.77 kB
Size
8.92 kB
File Count
15
NPM Version
10.9.0
Node Version
22.12.0
Publised On
01 Jan 2025
Total Downloads
Cumulative downloads
Total Downloads
2,447,413
Last day
-1.7%
2,239
Compared to previous day
Last week
-32.7%
18,206
Compared to previous week
Last month
-8.3%
146,358
Compared to previous month
Last year
149.9%
1,615,634
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
32
This package makes it possible to use Happy DOM with Jest.
Installation
1npm install @happy-dom/jest-environment --save-dev
Setup
Jest uses node
as test environment by default. In order to tell Jest to use a different environment we will either have to set a CLI attribute, define it in "package.json" or add a property to your Jest config file.
CLI
When calling the "jest" command, add --env=@happy-dom/jest-environment
as an attribute.
1jest --env=@happy-dom/jest-environment
Package.json
It is possible to add your Jest config to your package.json
.
1{ 2 "jest": { 3 "testEnvironment": "@happy-dom/jest-environment" 4 } 5}
Jest Config File
When using a Jest config file (usually jest.config.js), add the snippet below to it.
1{ 2 "testEnvironment": "@happy-dom/jest-environment" 3}
Options
It is possible to send in Happy DOM Browser Settings as environment options to Jest.
1{ 2 "testEnvironment": "@happy-dom/jest-environment", 3 "testEnvironmentOptions": { 4 "url": "http://localhost", 5 "width": 1920, 6 "height": 1080, 7 "settings": { 8 "navigator": { 9 "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" 10 } 11 } 12 } 13}
Happy DOM
Documentation | Getting Started | Setup as Test Environment | GitHub
No vulnerabilities found.
Reason
30 commit(s) and 18 issue activity found in the last 90 days -- score normalized to 10
Reason
security policy file detected
Details
- Info: security policy file detected: SECURITY.md:1
- Info: Found linked content: SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1
- Info: Found text in security policy: SECURITY.md:1
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
SAST tool is not run on all commits -- score normalized to 6
Details
- Warn: 18 commits out of 30 are checked with a SAST tool
Reason
Found 12/29 approved changesets -- score normalized to 4
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pull_request.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/pull_request.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pull_request.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/pull_request.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/pull_request.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/pull_request.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pull_request.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/pull_request.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pull_request.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/pull_request.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pull_request.yml:49: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/pull_request.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:61: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:68: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:73: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:76: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:87: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:129: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:135: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:140: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:159: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/capricorn86/happy-dom/release.yml/master?enable=pin
- Info: 0 out of 16 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
- Info: 4 out of 4 npmCommand dependencies pinned
Reason
6 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-96g7-g7g9-jxw8
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/auto-assign.yml:1
- Warn: no topLevel permission defined: .github/workflows/pull_request.yml:1
- Warn: no topLevel permission defined: .github/workflows/release.yml:1
- Info: no jobLevel write permissions found
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Score
6
/10
Last Scanned on 2024-12-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More