Skip to content

Commit

Permalink
test: add testFail JS integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
agostbiro committed Sep 10, 2024
1 parent 06f314a commit 9e5ce48
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions js/integration-tests/solidity-tests/contracts/TestFail.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.24;

contract TestFailTest {
function testFailRevert() public pure {
require(false, "should revert here");
}
}
24 changes: 24 additions & 0 deletions js/integration-tests/solidity-tests/test/unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,30 @@ describe("Unit tests", () => {
});
});

describe("TestFail", function () {
it("TestFail on", async function () {
const { totalTests, failedTests } = await testContext.runTestsWithStats(
"TestFailTest",
{
testFail: true,
}
);

// Reverting test starting with `testFail` should be reported as success if `testFail` is on
assert.equal(failedTests, 0);
assert.equal(totalTests, 1);
});

it("TestFail off", async function () {
const { totalTests, failedTests } =
await testContext.runTestsWithStats("TestFailTest");

// Reverting test starting with `testFail` should be reported as failure if `testFail` is off
assert.equal(failedTests, 1);
assert.equal(totalTests, 1);
});
});

it("GlobalFork", async function () {
if (testContext.rpcUrl === undefined) {
this.skip();
Expand Down

0 comments on commit 9e5ce48

Please sign in to comment.