GithubHelp home page GithubHelp logo

hardhat-jest-plugin's People

Contributors

alcuadrado avatar dependabot[bot] avatar fvictorio avatar fzeoli avatar rryter avatar scnale avatar wighawag avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

hardhat-jest-plugin's Issues

Gas report doesn't output

I'm trying to use jest on all my packages in my monorepo. Thank you for creating this plugin!

Using this plugin I was able to make the tests work with hardhat. The issue I found is that when using the hardhat-gas-reporter plugin, the tests succeed but the plugin output, which should appear at the end, doesn't.

The plugin uses an environment variable to turn on. Using mocha, I have "gas-report": "env REPORT_GAS=true yarn run hardhat test" on my packages.json. What should I use for jest?

I'm using yarn 2 (berry).

Properly support "Watch Mode"

hardhat test:jest --watch should start Jest in "watch mode". It should also start a watcher for changes on the contract files, and recompile as soon as there are any changes. Since Jest is in "watch mode", it will automatically rerun the tests.

  • Potentially it's possible to integrate the hardhat-watch-plugin
  • Make sure to still display any stack traces or console.log output from solidity
  • Write tests for this
  • Write documentation

Error: Can't find a root directory while resolving a config file path.

I am getting this error while trying to run hardhat test:jest on windows.

C:\repos\myProject\contracts>npr contracts:jest

> [email protected] contracts:jest
> hardhat test:jest --no-compile

You have both ethereum-waffle and @nomicfoundation/hardhat-chai-matchers installed. They don't work correctly together, so please make sure you only use one.

We recommend you migrate to @nomicfoundation/hardhat-chai-matchers. Learn how to do it here: https://hardhat.org/migrate-from-waffle
An unexpected error occurred:

Error: Can't find a root directory while resolving a config file path.
Provided path to resolve: C:\Users\Qwerty\repos\myProject\contracts/jest.config.js
cwd: C:\repos\myProject\contracts
    at resolveConfigPath (C:\Users\Qwerty\repos\myProject\contracts\node_modules\hardhat-jest-plugin\node_modules\jest-config\build\resolveConfigPath.js:134:11)
    at readConfig (C:\Users\Qwerty\repos\myProject\contracts\node_modules\hardhat-jest-plugin\node_modules\jest-config\build\index.js:228:49)
    at readConfigs (C:\Users\Qwerty\repos\myProject\contracts\node_modules\hardhat-jest-plugin\node_modules\jest-config\build\index.js:420:32)
    at runCLI (C:\Users\Qwerty\repos\myProject\contracts\node_modules\hardhat-jest-plugin\node_modules\@jest\core\build\cli\index.js:133:29)
    at testFailures (C:\Users\Qwerty\repos\myProject\contracts\node_modules\hardhat-jest-plugin\src\index.ts:20:14)
    at new Promise (<anonymous>)
    at SimpleTaskDefinition.action (C:\Users\Qwerty\repos\myProject\contracts\node_modules\hardhat-jest-plugin\src\index.ts:15:32)
    at async Environment._runTaskDefinition (C:\Users\Qwerty\repos\myProject\contracts\node_modules\hardhat\src\internal\core\runtime-environment.ts:219:14)
    at async Environment.run (C:\Users\Qwerty\repos\myProject\contracts\node_modules\hardhat\src\internal\core\runtime-environment.ts:131:14)
    at async SimpleTaskDefinition.action (C:\Users\Qwerty\repos\myProject\contracts\node_modules\hardhat-jest-plugin\src\index.ts:48:28)
(node:49648) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

But then when I run npx jest --showConfig it does read my jest.config.ts correctly, which can be seen from the output:

C:\repos\myProject\contracts>npx jest --showConfig
{
  "configs": [
    {
      "cwd": "C:\\Users\\Qwerty\\repos\\myProject\\contracts",
      "displayName": {
        "name": "Contracts",
        "color": "white"
      },

This is my jest.config.ts

import type { Config } from '@jest/types'

const config: Config.InitialOptions = {
  displayName: {
    name: 'Contracts',
    color: 'white',
  },

  testEnvironment: 'node',
  testRegex: 'test/.*\\.(ts|tsx)$',
  rootDir: '.',

  moduleNameMapper: {
    '^@abi/(.*)': '<rootDir>/abi/$1',
    '^@typings$': '<rootDir>/typings',
    '^@typings/(.*)': '<rootDir>/typings/$1',
  },

  silent: false,
  verbose: false,
}

export default config

What I am finding odd is the weird forward slash where it should have been a backwards slash. And then it actually tries to load jest.config.js instead of .ts

Provided path to resolve: C:\Users\Qwerty\repos\myProject\contracts/jest.config.js

What should I do?

Tests

  • Write actual tests

agurment

how can I pass arguments to jest configs?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.