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

[Test]: Jest to Vitest migration caravan-wallet package #155

Open
wants to merge 5 commits into
base: vite-migration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
449 changes: 99 additions & 350 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"build:coordinator": "turbo build --filter=caravan-coordinator",
"changeset": "changeset",
"ci": "turbo run build lint test",
"test": "turbo test",
"dev": "turbo dev",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"gen": "turbo gen run",
"lint": "turbo lint",
"test": "turbo test",
"version": "turbo run build lint test && changeset version && npm install --package-lock-only",
"release": "turbo run build lint test && changeset publish",
"dev:coordinator": "turbo run dev --filter=caravan-coordinator"
Expand All @@ -21,9 +21,9 @@
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@vitejs/plugin-react": "^4.3.1",
"vitest": "^2.0.5",
"prettier": "^3.1.1",
"turbo": "^2.0.3"
"turbo": "^2.0.3",
"vitest": "^2.0.5"
},
"dependencies": {
"@ledgerhq/hw-transport-webusb": "6.27.12"
Expand Down
22 changes: 0 additions & 22 deletions packages/caravan-wallets/jest.config.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/caravan-wallets/jest.setup.ts

This file was deleted.

14 changes: 3 additions & 11 deletions packages/caravan-wallets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,18 @@
"@caravan/eslint-config": "*",
"@caravan/multisig": "*",
"@caravan/typescript-config": "*",
"@inrupt/jest-jsdom-polyfills": "^3.2.1",
"@types/jest": "^29.5.12",
"@types/node": "^18.13.0",
"@types/w3c-web-usb": "^1.0.6",
"@typescript-eslint/parser": "^5.51.0",
"babel-jest": "^29.7.0",
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
"esbuild-plugin-polyfill-node": "^0.3.0",
"eslint": "^8.34.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^23.0.3",
"husky": "^8.0.3",
"jest": "^29.4.2",
"jest-environment-jsdom": "^29.4.1",
"jest-junit": "^9.0.0",
"jsdoc": "^4.0.0",
"lint-staged": "^13.1.2",
"mocha": "^10.2.0",
"prettier": "^2.8.4",
"ts-jest": "^29.0.5",
"tsup": "^7.2.0",
"typescript": "^4.9.5"
},
Expand All @@ -72,9 +64,9 @@
"build": "tsup src/index.ts --format cjs,esm --dts",
"ci": "npm run lint && npm run test",
"dev": "npm run build -- --watch",
"test": "jest src",
"test:watch": "jest --watch src",
"test:debug": "node --inspect-brk ../../node_modules/.bin/jest --runInBand",
"test": "vitest --watch=false src",
"test:watch": "vitest --watch src ",
"test:debug": "node --inspect-brk vitest --runInBand",
"docs": "./bin/build-docs.sh",
"lint": "eslint src --ignore-pattern src/vendor"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { BCUREncoder, BCURDecoder } from "./bcur";
import { BCUREncoder, BCURDecoder } from "../bcur";

import * as vendorEncodeUR from "./vendor/bcur/encodeUR";
import * as vendorDecodeUR from "./vendor/bcur/decodeUR";
import * as vendorEncodeUR from "../vendor/bcur/encodeUR";
import * as vendorDecodeUR from "../vendor/bcur/decodeUR";

import { vi, describe, it, expect, afterEach, beforeEach } from "vitest";

describe("BCUREncoder", () => {
describe("parts", () => {
afterEach(() => {
jest.clearAllMocks();
vi.clearAllMocks();
});
it("it returns encoded UR parts", () => {
const parts = ["a", "b"];
const encodeMock = jest
const encodeMock = vi
.spyOn(vendorEncodeUR, "encodeUR")
.mockReturnValue(parts);
const encoder = new BCUREncoder("deadbeef", 250);
Expand Down Expand Up @@ -57,11 +59,11 @@ describe("BCURDecoder", () => {

describe("receivePart", () => {
beforeEach(() => {
decodeMock = jest.spyOn(vendorDecodeUR, "smartDecodeUR");
decodeMock = vi.spyOn(vendorDecodeUR, "smartDecodeUR");
});

afterEach(() => {
jest.resetAllMocks();
vi.resetAllMocks();
});

it("delegates to smartDecodeUR", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/**
* @jest-environment jsdom
*/
// @vitest-environment jsdom

import {
ColdcardExportPublicKey,
ColdcardExportExtendedPublicKey,
ColdcardSignMultisigTransaction,
ColdcardMultisigWalletConfig,
} from "./coldcard";
} from "../coldcard";
import { Network, TEST_FIXTURES, ROOT_FINGERPRINT } from "@caravan/bitcoin";
import { INFO, PENDING, ACTIVE, ERROR } from "./interaction";
import { coldcardFixtures } from "./fixtures/coldcard.fixtures";
import { INFO, PENDING, ACTIVE, ERROR } from "../interaction";
import { coldcardFixtures } from "../fixtures/coldcard.fixtures";

import { describe, it, expect, beforeEach } from "vitest";

const { multisigs, transactions } = TEST_FIXTURES;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* @jest-environment jsdom
*/
// @vitest-environment jsdom

import {
CustomExportExtendedPublicKey,
CustomSignMultisigTransaction,
} from "./custom";
} from "../custom";
import { Network, TEST_FIXTURES } from "@caravan/bitcoin";
import { INFO, PENDING, ACTIVE, ERROR } from "./interaction";
import { customFixtures } from "./fixtures/custom.fixtures";
import { INFO, PENDING, ACTIVE, ERROR } from "../interaction";
import { customFixtures } from "../fixtures/custom.fixtures";

import { describe, it, expect } from "vitest";

const { multisigs, transactions } = TEST_FIXTURES;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* @jest-environment jsdom
*/
// @vitest-environment jsdom

import { PENDING, INFO } from "./interaction";
import { PENDING, INFO } from "../interaction";
import {
HermitExportExtendedPublicKey,
HermitSignMultisigTransaction,
} from "./hermit";
} from "../hermit";

import { describe, it, expect } from "vitest";

function itHasACommandMessage(interaction, command) {
const message = interaction.messageFor({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/**
* @jest-environment jsdom
*/
// @vitest-environment jsdom

import {
UNSUPPORTED,
Expand All @@ -13,7 +11,9 @@ import {
DirectKeystoreInteraction,
UnsupportedInteraction,
IndirectKeystoreInteraction,
} from "./interaction";
} from "../interaction";

import { describe, it, expect } from "vitest";

describe("KeystoreInteraction", () => {
class TestKeystoreInteraction extends KeystoreInteraction {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/**
* @jest-environment jsdom
*/
// @vitest-environment jsdom

import { TEST_FIXTURES, ROOT_FINGERPRINT, Network } from "@caravan/bitcoin";
import { PENDING, ACTIVE, INFO, WARNING, ERROR } from "./interaction";
import { PENDING, ACTIVE, INFO, WARNING, ERROR } from "../interaction";
import {
LedgerGetMetadata,
LedgerExportPublicKey,
Expand All @@ -14,9 +12,11 @@ import {
LedgerConfirmMultisigAddress,
LedgerV2SignMultisigTransaction,
LedgerSignatures,
} from "./ledger";
} from "../ledger";
import { BraidDetails, braidDetailsToWalletConfig } from "@caravan/multisig";

import { describe, it, expect, beforeEach, afterEach } from "vitest";

function itHasStandardMessages(interactionBuilder) {
it("has a message about ensuring your device is plugged in", () => {
expect(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/**
* @jest-environment jsdom
*/

import { Network, TEST_FIXTURES } from "@caravan/bitcoin";
import {
KeyOrigin,
validateMultisigPolicyTemplate,
getPolicyTemplateFromWalletConfig,
braidDetailsToWalletConfig,
MultisigWalletPolicy,
} from "./policy";
import { POLICY_FIXTURE } from "./fixtures";
} from "../policy";
import { POLICY_FIXTURE } from "../fixtures";
import { BraidDetails, MultisigWalletConfig } from "@caravan/multisig";

import { describe, it, expect, beforeEach } from "vitest";

describe("validateMultisigPolicyTemplate", () => {
it("throws error if script type is not supported", () => {
const templates = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/**
* @jest-environment jsdom
*/
// @vitest-environment jsdom

import {
ROOT_FINGERPRINT,
Expand All @@ -9,7 +7,9 @@ import {
networkData,
Network,
} from "@caravan/bitcoin";
import { PENDING, ACTIVE, INFO, ERROR } from "./interaction";
import { PENDING, ACTIVE, INFO, ERROR } from "../interaction";

import { describe, it, expect } from "vitest";

import {
trezorCoin,
Expand All @@ -21,7 +21,7 @@ import {
TrezorSignMultisigTransaction,
TrezorConfirmMultisigAddress,
TrezorSignMessage,
} from "./trezor";
} from "../trezor";
import { ECPair, payments } from "bitcoinjs-lib";

import TrezorConnect from "@trezor/connect-web";
Expand Down
Loading