Skip to content

Commit

Permalink
Merge pull request #1 from bobanetwork/wsdt/test-configuration
Browse files Browse the repository at this point in the history
Wsdt/test configuration
  • Loading branch information
wsdt authored Apr 4, 2024
2 parents 6b18e71 + 61ad54a commit e5dbddc
Show file tree
Hide file tree
Showing 11 changed files with 6,851 additions and 8 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ node_modules/.pnpm
.idea/
node_modules/.tsup
node_modules/.bin
node_modules/**/*
node_modules/**/*

/coverage/lcov-report
/coverage/coverage-summary.json
/coverage/lcov.info
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
# light-bridge-chains
Chain Configs for Light Bridge

# Testing

> Run tests
```yarn test```

> Run tests with coverage
>
```yarn test-coverage```

<img src="coverage/badge-lines.svg" alt="Line Coverage">
<br>
<img src="coverage/badge-branches.svg" alt="Branch Coverage">
<br>
<img src="coverage/badge-functions.svg" alt="Function Coverage">
<br>
<img src="coverage/badge-statements.svg" alt="Function Coverage">
<br>
1 change: 1 addition & 0 deletions coverage/badge-branches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions coverage/badge-functions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions coverage/badge-lines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions coverage/badge-statements.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { defaults } = require('jest-config')

/** @type {import('jest').Config} */
const config = {
moduleFileExtensions: [
...defaults.moduleFileExtensions,
'mts',
'cts',
'd.ts',
],
preset: 'ts-jest',
testEnvironment: 'node',
transform: {
'node_modules/variables/.+\\.(j|t)sx?$': 'ts-jest',
},
transformIgnorePatterns: ['node_modules/(?!variables/.*)'],
coverageReporters: [
"json-summary",
"text",
"lcov"
]
}

module.exports = config
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
],
"scripts": {
"build": "tsup",
"test": "node --test src/chains.test.ts"
"test": "jest",
"test:coverage": "yarn test -- --coverage --collectCoverageFrom='src/**/*.ts' && jest-coverage-badges"
},
"repository": {
"type": "git",
Expand All @@ -27,7 +28,11 @@
"ethers": "^5.5.4"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/node": "^16.18.62",
"jest": "^29.7.0",
"jest-coverage-badges": "^1.1.2",
"ts-jest": "^29.1.2",
"tsup": "^8.0.2",
"typescript": "^5.4.2"
}
Expand Down
11 changes: 5 additions & 6 deletions src/chains.test.ts → tests/unit/chains.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
const {describe, it} = require("node:test");
const assert = require("node:assert");
const {getRandomPublicRpc} = require("./chains.ts");
const {getRandomPublicRpc} = require("../../src/chains.ts");

describe("chains", () => {
it("should work", () => {
assert(true)
expect(1).toBe(1)
});

it("should get random RPC when only one element", () => {
const randomRPC = getRandomPublicRpc(288)
assert.strictEqual(randomRPC, "https://boba-ethereum.gateway.tenderly.co")
expect(randomRPC).toEqual("https://boba-ethereum.gateway.tenderly.co")
});

/** @DEV brittle */
it("should get random RPC with multiple endpoints & randomized", () => {
let randomRPCs = [getRandomPublicRpc(56), getRandomPublicRpc(56), getRandomPublicRpc(56), getRandomPublicRpc(56)]
const areDifferent = new Set(randomRPCs).size === randomRPCs.length
assert(areDifferent)
expect(areDifferent).toBe(false)
});
})
Loading

0 comments on commit e5dbddc

Please sign in to comment.