Socket
Socket
Sign inDemoInstall

jest-environment-hardhat

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-environment-hardhat - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

2

package.json
{
"name": "jest-environment-hardhat",
"version": "1.1.4",
"version": "1.1.5",
"description": "A jest environment with hardhat built in",

@@ -5,0 +5,0 @@ "repository": "https://github.com/Uniswap/jest-environment-hardhat",

@@ -9,9 +9,9 @@ # jest-environment-hardhat

`jest-environment-hardhat` is a drop-in jest environment for running hardhat inline with your tests. Instead of running a separate `hardhat node`, this environment runs a node and exposes a global `Hardhat` interface to interact with it.
`jest-environment-hardhat` is a drop-in jest environment for running hardhat inline with your tests. Instead of running a separate `hardhat node`, this environment runs a node and exposes a global `Hardhat` interface - with some helper utilities - to interact with it.
## Installation
First, install `jest-environment-hardhat` and its dependencies using `yarn`.
First, install `jest-environment-hardhat` and its dependencies (using `yarn` or `npm`).
The environment needs `@nomiclabs/hardhat-ethers`, `ethers`, and `hardhat` installed to run. These are installed as peer dependencies to ensure that you retain control over versioning.
The environment needs `@nomiclabs/hardhat-ethers`, `ethers`, and `hardhat` installed as well. These are installed as peer dependencies to ensure that you retain control over versioning, so you'll need to install them explicitly.

@@ -25,20 +25,24 @@ ```sh

`jest-environment-hardhat` extends a `node` environment by default. A `jsdom` environment is also available, using `jest-environment-hardhat/dist/jsdom`.
```
/**
* @jest-environment hardhat
*/
### Using a doc-comment
test('use hardhat in this test file', () => {
expect(hardhat).toBeDefined()
})
```
Files starting with a `@jest-environment` preamble use the specified runner:
`jest-environment-hardhat` extends a `node` environment by default. A `jsdom` environment is also available, using `hardhat/dist/jsdom`.
```js
```
/**
* @jest-environment jest-environment-hardhat
* @jest-environment hardhat/dist/jsdom
*/
```
### Using jest configuration
You may also configure your test environment through the `jest.config.js` file, using the [`testEnvironment`](https://jestjs.io/docs/configuration#testenvironment-string) property.
```json
"testEnvironment": "jest-environment-hardhat",
test('use hardhat and jsdom in this test file', () => {
expect(hardhat).toBeDefined()
const element = document.createElement('div')
expect(element).not.toBeNull()
})
```

@@ -48,5 +52,4 @@

`jest-environment-hardhat` exports a `node` and `jsdom` environment. If you'd like to extend your own environment, you can use the setup function exported by `jest-environment-hardhat/setup`. See [`src/node.ts`](./src/node.ts) for an example.
`jest-environment-hardhat` exports a `node` (by default) and `jsdom` environment. If you'd like to extend your own environment, you can use the setup function exported by `jest-environment-hardhat/setup`. See [`src/node.ts`](./src/node.ts) for an example.
## Documentation

@@ -53,0 +56,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc