-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: create a mocha/ethers template project #5806
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
fc68dbd
to
867b848
Compare
8f9369c
to
fb535c6
Compare
hardhatTotal size of the bundle: List of dependencies (sorted by size)
|
fb535c6
to
b979fdf
Compare
"@types/chai-as-promised": "^8.0.1", | ||
"@types/mocha": ">=9.1.0", | ||
"chai": "^4.4.1", | ||
"chai-as-promised": "^8.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may be able to drop the direct dev dependency once hardhat-chai-matchers
has been ported.
import * as chai from "chai"; | ||
import chaiAsPromised from "chai-as-promised"; | ||
chai.use(chaiAsPromised); | ||
const { expect } = chai; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I applied the chaiAsPromised
setup directly here.
I don't think we currently have support .mochars.json
files to allow us to setup up supporting setup files.
b979fdf
to
5badc23
Compare
5badc23
to
2b9a6b6
Compare
const { expect } = chai; | ||
|
||
describe("Lock", function () { | ||
let connection: NetworkConnection<"l1">; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that the connection is not ambient to the global context we need a new pattern for tests.
I have no strong feelings here so opted for a shared connection
that is explicitly typed for the expected network connection and that is setup for each test.
I suspect we may want to go with something other than connection
as the variable name. Maybe networkConnection
is less ambiguous?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to networkConnection
. That's the name I used in the network-manager
tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we need to reset it between tests, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a minor comment regarding the networkConnection
reset.
2b9a6b6
to
5e9955a
Compare
As part of the Alpha prep this adds a mocha/ethers template project that tries to recreate the functionality (we are currently able to support) of the v2 Ethers typescript project in v3. It pulls in the `v-next` versions of the mocha test runner, the `hardhat-test-helpers` and `hardhat-ethers`. It adds a the `Lock.sol` and `Lock.ts` test file. The test file has been modified to allow for running the tests while we still have rough edges. Specifically the rough edges are: - we need new patterns for sharing `connection` among tests (I added a `beforeEach`) - we don't have chai matchers so I added `chai-as-promised` and adapted the tests ... crudely.
5e9955a
to
84f8aef
Compare
As part of the Alpha prep this adds a mocha/ethers template project (used during
hardhat --init
), that tries to recreate the functionality (we are currently able to support`f of the v2 Ethers typescript project in v3.It pulls in the
v-next
versions of the mocha test runner, the test helpers andhardhat-ethers
.It adds a the
Lock.sol
andLock.ts
test file. The test file has been modified to allow for running the tests while we still have rough edges.Specifically the rough edges are:
connection
among tests (I added abeforeEach
)chai-as-promised
and adapted the tests, sometime crudely.