New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hardhat-jest

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hardhat-jest - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

hardhat-jest.png

2

package.json
{
"name": "hardhat-jest",
"version": "1.0.2",
"version": "1.0.3",
"description": "A Hardhat plugin for using Jest",

@@ -5,0 +5,0 @@ "main": "src/index.js",

# hardhat-jest
<a href="https://npmjs.com/package/hardhat-jest" target="_blank">
<img src="https://img.shields.io/badge/npm-CB3837?style=for-the-badge&logo=npm&logoColor=white"/>
<img src="https://img.shields.io/badge/Solidity-e6e6e6?style=for-the-badge&logo=solidity&logoColor=black"/>
<img src="https://img.shields.io/badge/Jest-C21325?style=for-the-badge&logo=jest&logoColor=white"/>
<img src="https://img.shields.io/badge/Ethereum-3C3C3D?style=for-the-badge&logo=Ethereum&logoColor=white"/>
</a>
<a style="display: block" target="_blank" href="https://npmjs.com/package/hardhat-jest"><img
src="hardhat-jest.png"
width='1200"' /></a>
[![Npm package version](https://badgen.net/npm/v/hardhat-jest)](https://npmjs.com/package/hardhat-jest)
Have you always wanted to use **Jest** instead of Mocha + Chai in your Hardhat Projects? 😉 Good News!

@@ -7,11 +19,11 @@

- [Installation](#installation)
- [Usage](#usage)
- [Options](#options): See all the available options
- [Hardhat Tasks](#hardhat-tasks): See all the Hardhat tasks
- [Installation](#installation)
- [Usage](#usage)
- [Options](#options): See all the available options
- [Hardhat Tasks](#hardhat-tasks): See all the Hardhat tasks
## Installation
First of all, Make sure that you have `jest` already installed!
## Installation
**Step 1:** Install the package

@@ -36,4 +48,5 @@

## Usage
It's so easy, You can run your Jest tests by
It's so easy, You can run your Jest tests by
```

@@ -45,3 +58,2 @@ npx hardhat jest

### Options

@@ -56,5 +68,5 @@

--no-compile Do NOT compile before running this task
--watch Watch files for changes and rerun tests related to changed files.
--watch-all Watch files for changes and rerun all tests
--no-compile Do NOT compile before running this task
--watch Watch files for changes and rerun tests related to changed files.
--watch-all Watch files for changes and rerun all tests

@@ -79,5 +91,5 @@ jest: Runs Jest tests

flatten Flattens and prints contracts and their dependencies
gas-reporter:merge
gas-reporter:merge
help Prints this message
> jest Runs Jest tests
> jest Runs Jest tests
node Starts a JSON-RPC server on top of Hardhat Network

@@ -89,8 +101,9 @@ run Runs a user-defined script after compiling the project

```
and There it is, `jest` task is added successfully! it means that you can run **`npx hardhat jest`** and your tests will be run!
## Final thoughts
## Final thoughts
Finally, show us some love by **starring** the repository on GitHub!️ 😊
Happy hacking!

@@ -6,7 +6,16 @@ const { task, subtask } = require("hardhat/config");

task("jest", "Runs Jest tests")
.addFlag("noCompile", "Do NOT compile before running this task")
.addFlag("watch", "Watch files for changes and rerun tests related to changed files.")
.addFlag("watchAll", "Watch files for changes and rerun all tests")
.addFlag("noCompile", "Do NOT compile before running this task.")
.addFlag(
"watch",
"Watch files for changes and rerun tests related to changed files."
)
.addFlag("watchAll", "Watch files for changes and rerun all tests.")
.addFlag("bail", "Stop running tests after the first test failure.")
.setAction(async (taskArgs, { run }) => {
const { watch: watchFlag, watchAll: watchAllFlag, noCompile: noCompileFlag } = taskArgs;
const {
watch: watchFlag,
watchAll: watchAllFlag,
noCompile: noCompileFlag,
bail: bailFlag,
} = await taskArgs;

@@ -19,13 +28,17 @@ // If --no-compile flag is added, then don't compile before running this task

// Call suntask jest:run
await run("jest:run", { watchFlag, watchAllFlag });
await run("jest:run", { watchFlag, watchAllFlag, bailFlag });
});
subtask("jest:run").setAction(async ({ watchFlag, watchAllFlag }) => {
subtask("jest:run").setAction(async ({ watchFlag, watchAllFlag, bailFlag }) => {
const projectRootPath = [config.paths.root];
const jestOptions = { watch: watchFlag, watchAll: watchAllFlag ? true : undefined };
const jestOptions = {
watch: watchFlag,
watchAll: watchFlag ? undefined : watchAllFlag,
bail: bailFlag,
};
await runCLI(jestOptions, projectRootPath)
.then()
.then((result) => result)
.catch((error) => console.error(error));
});
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