Skip to content

Commit

Permalink
move web3 package to vitest (#1578)
Browse files Browse the repository at this point in the history
stacked on top of #1576

I'm breaking #1462 into small PRs

Moving the web3 package from jest to vitest.
Tests are running in concurrent mode
  • Loading branch information
miguel-nascimento authored Nov 21, 2024
1 parent f4ccc09 commit 6a809f2
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 117 deletions.
13 changes: 8 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@
"console": "integratedTerminal",
},
{
"name": "Jest: current file in 'packages/web3/'",
"name": "Vitest: current file in 'packages/web3/'",
"type": "node",
"request": "launch",
"env": { "NODE_ENV": "development", "NODE_TLS_REJECT_UNAUTHORIZED": "0", "NODE_EXTRA_CA_CERTS":"~/river-ca-cert.pem" },
"program": "${workspaceFolder}/node_modules/.bin/jest",
"runtimeArgs": ["--experimental-vm-modules", "--experimental-wasm-modules"],
"args": ["${file}", "--config", "${workspaceFolder}/packages/web3/jest.config.ts", "-i", "--no-cache", "--forceExit"],
"env": { "NODE_ENV": "development" },
"program": "${workspaceFolder}/node_modules/vitest/vitest.mjs",
"cwd": "${workspaceFolder}/packages/web3",
"autoAttachChildProcesses": true,
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"smartStep": true,
"args": ["run", "${fileBasename}", "--config", "vitest.config.ts"],
"console": "integratedTerminal",
},
{
Expand Down
9 changes: 2 additions & 7 deletions packages/web3/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
"plugin:import/typescript",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:prettier/recommended",
"plugin:jest/recommended"
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": { "project": ["./tsconfig.eslint.json"] },
"plugins": ["@typescript-eslint", "import"],
"ignorePatterns": ["dist/**", ".turbo/**", "node_modules/**", "jest.config.ts"],
"ignorePatterns": ["dist/**", ".turbo/**", "node_modules/**", "vitest.config.ts"],
"rules": {
"no-console": "error",
"import/no-extraneous-dependencies": [
Expand Down Expand Up @@ -54,10 +53,6 @@
{
"files": ["**/*.test.*"],
"rules": {
"jest/no-standalone-expect": "off",
"jest/expect-expect": "off",
"jest/no-conditional-expect": "off",
"jest/no-disabled-tests": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-non-null-assertion": "off",
Expand Down
3 changes: 0 additions & 3 deletions packages/web3/jest-setup.ts

This file was deleted.

35 changes: 0 additions & 35 deletions packages/web3/jest.config.ts

This file was deleted.

15 changes: 5 additions & 10 deletions packages/web3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"clean": "rm -rf dist",
"lint": "yarn eslint --format unix ./src",
"lint:fix": "yarn lint --fix",
"my-jest": "NODE_EXTRA_CA_CERTS=${HOME}/river-ca-cert.pem yarn node --trace-warnings -r ../../scripts/node-no-warn.js --experimental-vm-modules --experimental-wasm-modules $(yarn bin jest)",
"test": "yarn my-jest",
"test": "vitest run",
"test:watch": "vitest --watch",
"test:ci": "yarn test",
"test:debug": "DEBUG=test yarn my-jest",
"test:debug": "DEBUG=test yarn test",
"watch": "tsc --watch"
},
"dependencies": {
Expand All @@ -31,7 +31,6 @@
"zod": "^3.21.4"
},
"devDependencies": {
"@types/jest": "^29.5.3",
"@types/lodash": "^4.14.186",
"@types/node": "^20.5.0",
"@typescript-eslint/eslint-plugin": "^6.10.0",
Expand All @@ -40,13 +39,9 @@
"eslint": "^8.53.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.3",
"jest": "^29.6.2",
"jest-extended": "^4.0.1",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typed-emitter": "^2.1.0",
"typescript": "^5.1.6"
"typescript": "^5.1.6",
"vitest": "^2.1.5"
},
"files": [
"/dist",
Expand Down
12 changes: 6 additions & 6 deletions packages/web3/src/EntitlementCache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class StringCacheResult implements CacheResult<string> {
}

describe('EntitlementsCacheTests', () => {
test('caches repeat positive values', async () => {
it('caches repeat positive values', async () => {
const cache = new EntitlementCache<Key, boolean>({
positiveCacheTTLSeconds: 10,
negativeCacheTTLSeconds: 10,
Expand All @@ -59,7 +59,7 @@ describe('EntitlementsCacheTests', () => {
expect(cacheHit2).toBe(true)
})

test('caches repeat negative values', async () => {
it('caches repeat negative values', async () => {
const cache = new EntitlementCache<Key, boolean>({
positiveCacheTTLSeconds: 10,
negativeCacheTTLSeconds: 10,
Expand All @@ -81,7 +81,7 @@ describe('EntitlementsCacheTests', () => {
expect(cacheHit2).toBe(true)
})

test('caches non-boolean positive values', async () => {
it('caches non-boolean positive values', async () => {
const cache = new EntitlementCache<Key, string>({
positiveCacheTTLSeconds: 10,
negativeCacheTTLSeconds: 10,
Expand All @@ -103,7 +103,7 @@ describe('EntitlementsCacheTests', () => {
expect(cacheHit2).toBe(true)
})

test('caches non-boolean falsy keys', async () => {
it('caches non-boolean falsy keys', async () => {
const cache = new EntitlementCache<Key, string>({
positiveCacheTTLSeconds: 10,
negativeCacheTTLSeconds: 10,
Expand All @@ -125,7 +125,7 @@ describe('EntitlementsCacheTests', () => {
expect(cacheHit2).toBe(true)
})

test('positive cache values expire after ttl', async () => {
it('positive cache values expire after ttl', async () => {
const cache = new EntitlementCache<Key, boolean>({
positiveCacheTTLSeconds: 1,
negativeCacheTTLSeconds: 10,
Expand All @@ -150,7 +150,7 @@ describe('EntitlementsCacheTests', () => {
expect(cacheHit2).toBe(false)
})

test('negative cache values expire after ttl', async () => {
it('negative cache values expire after ttl', async () => {
const cache = new EntitlementCache<Key, boolean>({
positiveCacheTTLSeconds: 10,
negativeCacheTTLSeconds: 1,
Expand Down
4 changes: 2 additions & 2 deletions packages/web3/src/Web3Constants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const log = debug('web3:test')

describe('Web3Constants', () => {
;``
test('BASE_SEPOLIA', () => {
it('BASE_SEPOLIA', () => {
expect(BASE_SEPOLIA).toBe(84532)
})

test('instantiate provider', () => {
it('instantiate provider', () => {
log('testing provider instanciation')
const p = new LocalhostWeb3Provider('http://localhost:8545')
expect(p).toBeDefined()
Expand Down
Loading

0 comments on commit 6a809f2

Please sign in to comment.