Skip to content

Commit

Permalink
add chai-setup script to consistently import additional matchers if n…
Browse files Browse the repository at this point in the history
…eeded (#537)

Co-authored-by: jordan <[email protected]>
  • Loading branch information
jordaniza and terrylovesyoghurt authored Feb 14, 2024
1 parent 3cf4160 commit 8834c37
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,13 @@ Please replace 'MyContract' with the actual name of your contract, and follow th
Example of usage in a test:

```ts
// chai-setup imports additional matchers used for mocking
import {expect} from './chai-setup';
import {
DAO as DAO_V1_3_0,
DAO__factory as DAO_V1_3_0_factory,
} from '@aragon/osx-ethers-v1.3.0/contracts/core/dao/DAO.sol';
import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers';
import {expect} from 'chai';
import {ethers} from 'hardhat';

describe('Legacy Test Example', function () {
Expand Down
10 changes: 10 additions & 0 deletions packages/contracts/test/chai-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Enable additional matchers for chai and smock
* import this file in place of chai, i.e:
* import {expect} from './chai-setup';
**/
import {smock} from '@defi-wonderland/smock';
import chai from 'chai';

chai.use(smock.matchers);
export = chai;
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
PluginCloneableSetupV1MockBad__factory,
} from '../../../typechain';
import {PluginRepoRegisteredEvent} from '../../../typechain/PluginRepoRegistry';
import {expect} from '../../chai-setup';
import {deployNewDAO, ZERO_BYTES32} from '../../test-utils/dao';
import {deployENSSubdomainRegistrar} from '../../test-utils/ens';
import {deployPluginSetupProcessor} from '../../test-utils/plugin-setup-processor';
Expand Down Expand Up @@ -84,7 +85,6 @@ import {
import {MockContract, smock} from '@defi-wonderland/smock';
import {anyValue} from '@nomicfoundation/hardhat-chai-matchers/withArgs';
import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers';
import {expect} from 'chai';
import {BytesLike} from 'ethers';
import {ethers} from 'hardhat';

Expand Down

0 comments on commit 8834c37

Please sign in to comment.