Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrating intellij test buttons with hardhat typescript project #196

Open
EvgeniiaVak opened this issue Feb 15, 2023 · 4 comments
Open
Assignees
Labels
enhancement New feature or request pinned

Comments

@EvgeniiaVak
Copy link

Intellij has this super useful buttons to launch tests one by one or all together:
Screenshot 2023-02-15 at 14 56 46

Unfortunately when using them with a typescript project created by hardhat extension they don't work, resulting in this error:

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"
...

It's probably not a bug, because the command npx hardhat test in the terminal works perfectly fine.

The closest solution to this problem I found here but I don't quite understand how to apply it and it looks like even if I figure it out it only will solve the problem for one configuration and if I press another green button to launch a different test, I would need to apply the same fix again, which kind of defeats the purpose of using those buttons to simplify things.

It would be super helpful if that buttons just worked out of the box.

Here is the demo project which is just the project generated by the hardhat extension itself - https://github.com/EvgeniiaVak/demo-hardhat

  • the hardhat config created manually works fine
  • the auto-config created almost automatically by pressing the green button (I still needed to select where the mocha resides) does not work
@EvgeniiaVak EvgeniiaVak added the enhancement New feature or request label Feb 15, 2023
@EvgeniiaVak
Copy link
Author

Does this sound like a desired improvement for the plugin? Can I help somehow (if so, where to start)?

@MG-Pro
Copy link

MG-Pro commented Apr 5, 2023

Much needed feature

@EvgeniiaVak
Copy link
Author

🎉 Solved, at least in one project. To make the juicy green buttons work I had to add .mocharc.json (this is for mocha to know its defaults, so you don't need to manually fix run-debug-configurations each time):

{
  "extension": [
    "ts"
  ],
  "spec": "test/**/*.ts",
  "require": "ts-node/register"
}

and these lines to tsconfig.json:

  "include": ["./scripts", "./test", "./typechain-types"],
  "files": ["./hardhat.config.ts"]

I wonder why npx hardhat test worked without all that 🤔

Now, to make it all work out of the box, I need to find where this demo project is created, in the extension or somewhere in hardhat itself. I suspect it's the latter. There is also this issue (that I faced when only adding .mocharc.json, and not yet editing tsconfig.json)

@EvgeniiaVak
Copy link
Author

The issue is on Hardhat side, I checked it out without any IDE, just with the terminal - the same.

@nekofar nekofar reopened this Jun 24, 2023
@nekofar nekofar added the pinned label Jun 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pinned
Projects
None yet
Development

No branches or pull requests

3 participants