Skip to content

Commit

Permalink
chore: stop removing fuel-ts/utils node modules on unit test (#1692)
Browse files Browse the repository at this point in the history
  • Loading branch information
Torres-ssf authored Feb 1, 2024
1 parent af66671 commit d261154
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 103 deletions.
2 changes: 2 additions & 0 deletions .changeset/honest-parrots-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
8 changes: 0 additions & 8 deletions packages/abi-coder/src/coders/boolean.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils';

import { BooleanCoder } from './boolean';

vi.mock('@fuel-ts/math', async () => {
const mod = await vi.importActual('@fuel-ts/math');
return {
__esModule: true,
...mod,
};
});

/**
* @group node
*/
Expand Down
17 changes: 0 additions & 17 deletions packages/abi-typegen/test/utils/mockVersions.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
import * as versionsMod from '@fuel-ts/versions';

// TODO: Check if there's a better alternative to this
/**
* This makes it possible to mock modules that are exported
* from package's index files, using exports syntax such as:
*
* export * from '...'
*
* https://stackoverflow.com/a/72885576
*/
vi.mock('@fuel-ts/versions', async () => {
const mod = await vi.importActual('@fuel-ts/versions');
return {
__esModule: true,
...mod,
};
});

export function mockVersions(
values: {
FUELS: string;
Expand Down
8 changes: 0 additions & 8 deletions packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ import type { FuelsConfig } from '../../types';
import type { FuelCoreNode } from './autoStartFuelCore';
import { autoStartFuelCore } from './autoStartFuelCore';

vi.mock('@fuel-ts/wallet/test-utils', async () => {
const mod = await vi.importActual('@fuel-ts/wallet/test-utils');
return {
__esModule: true,
...mod,
};
});

/**
* @group node
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ import { mockLogger } from '../../../../test/utils/mockLogger';

import { shouldUseBuiltinFuelCore } from './shouldUseBuiltinFuelCore';

vi.mock('@fuel-ts/versions/cli', async () => {
const mod = await vi.importActual('@fuel-ts/versions/cli');
return {
__esModule: true,
...mod,
};
});

vi.mock('prompts', async () => {
const mod = await vi.importActual('prompts');
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ import { mockLogger } from '../../../../test/utils/mockLogger';

import { shouldUseBuiltinForc } from './shouldUseBuiltinForc';

vi.mock('@fuel-ts/versions/cli', async () => {
const mod = await vi.importActual('@fuel-ts/versions/cli');
return {
__esModule: true,
...mod,
};
});

/**
* @group node
*/
Expand Down
3 changes: 1 addition & 2 deletions packages/providers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,15 @@
"@fuel-ts/math": "workspace:*",
"@fuel-ts/hasher": "workspace:*",
"@fuel-ts/transactions": "workspace:*",
"ethers": "^6.7.1",
"@fuel-ts/versions": "workspace:*",
"ethers": "^6.7.1",
"graphql": "^16.6.0",
"graphql-request": "5.0.0",
"graphql-tag": "^2.12.6",
"ramda": "^0.29.0",
"tai64": "^1.0.0"
},
"devDependencies": {
"@fuel-ts/utils": "workspace:*",
"@graphql-codegen/cli": "^2.13.7",
"@graphql-codegen/typescript": "^2.8.0",
"@graphql-codegen/typescript-operations": "^2.5.5",
Expand Down
16 changes: 0 additions & 16 deletions packages/providers/test/provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,6 @@ import * as gasMod from '../src/utils/gas';

import { messageProofResponse, messageStatusResponse } from './fixtures';

vi.mock('@fuel-ts/versions', async () => {
const mod = await vi.importActual('@fuel-ts/versions');
return {
__esModule: true,
...mod,
};
});

vi.mock('@fuel-ts/math', async () => {
const mod = await vi.importActual('@fuel-ts/math');
return {
__esModule: true,
...mod,
};
});

afterEach(() => {
vi.restoreAllMocks();
});
Expand Down
4 changes: 1 addition & 3 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@
"license": "Apache-2.0",
"dependencies": {
"@fuel-ts/interfaces": "workspace:*",
"@fuel-ts/errors": "workspace:*",
"ramda": "^0.29.0",
"rimraf": "^3.0.2"
},
"devDependencies": {
"@fuel-ts/errors": "workspace:*"
}
}
10 changes: 8 additions & 2 deletions packages/utils/src/cli-utils/findBinPath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ describe('findBinPath', () => {
const bin = join(mods, '.bin');
const cmdPath = join(bin, cmdName);

const resetDisk = () => rmSync(mods, { recursive: true });
const resetDisk = (params?: { cmdOnly: boolean }) => {
if (params?.cmdOnly) {
rmSync(cmdPath);
} else {
rmSync(mods, { recursive: true });
}
};

mkdirSync(bin, { recursive: true });
writeFileSync(cmdPath, '');
Expand Down Expand Up @@ -45,7 +51,7 @@ describe('findBinPath', () => {
const { cmdName, cmdPath, resetDisk } = bootstrap(base);
const binPath = findBinPath(cmdName, base);

resetDisk();
resetDisk({ cmdOnly: true });
expect(binPath).toEqual(cmdPath);
});

Expand Down
8 changes: 0 additions & 8 deletions packages/wallet/src/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ import type { TxParamsType } from './account';
import { Account } from './account';
import { FUEL_NETWORK_URL } from './configs';

vi.mock('@fuel-ts/providers', async () => {
const mod = await vi.importActual('@fuel-ts/providers');
return {
__esModule: true,
...mod,
};
});

let provider: Provider;

afterEach(() => {
Expand Down
8 changes: 0 additions & 8 deletions packages/wallet/src/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ import {
formatScriptDataForTransferringToContract,
} from './utils';

vi.mock('@fuels/vm-asm', async () => {
const mod = await vi.importActual('@fuels/vm-asm');
return {
__esModule: true,
...mod,
};
});

vi.mock('ethers', async () => {
const mod = await vi.importActual('ethers');
return {
Expand Down
8 changes: 0 additions & 8 deletions packages/wallet/src/wallet-unlocked.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ import * as keystoreWMod from './keystore-wallet';
import walletSpec from './wallet-spec';
import { WalletLocked, WalletUnlocked } from './wallets';

vi.mock('@fuel-ts/providers', async () => {
const mod = await vi.importActual('@fuel-ts/providers');
return {
__esModule: true,
...mod,
};
});

const { ScriptTransactionRequest } = providersMod;

/**
Expand Down
10 changes: 3 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d261154

Please sign in to comment.