-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: custom test environment * feat: custom test environment * fix: adding TextDecoder to the custom env * feat: replacing ws with isomorphic-ws * feat: adding tests in browser env * fix: fix failing tests * fix: fix failing tests * feat: adding browser tests in GitHub workflow * feat: set custom test environment for browser * chore: update sonar properties * chore: set browser test environment config * revert: hardhat plugin browser tests * docs: updating readme --------- Co-authored-by: Fabio Rigamonti <[email protected]> Co-authored-by: Fabio Rigamonti <[email protected]>
- Loading branch information
1 parent
7115e99
commit 0179eb7
Showing
24 changed files
with
436 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Run unit tests | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
name: Build & Lint | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node: [18, lts/*, latest] | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
|
||
- name: Install & Patch packages | ||
run: yarn install | ||
|
||
- name: Preliminary Stop of Thor solo node | ||
id: preliminary-stop-solo | ||
run: yarn stop-thor-solo | ||
|
||
- name: Start Thor solo node | ||
id: start-solo | ||
run: yarn start-thor-solo | ||
|
||
- name: Test | ||
id: unit-test | ||
run: yarn test:browser | ||
|
||
- name: Stop Thor solo node | ||
id: stop-solo | ||
run: yarn stop-thor-solo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { TestEnvironment } = require('jest-environment-jsdom'); | ||
|
||
/** | ||
* Jest creates a new VM context for each test and doesn't add in all | ||
* the node globals. | ||
* We rectify this here. | ||
*/ | ||
class CustomizedTestEnvironment extends TestEnvironment { | ||
constructor(config, context) { | ||
super(config, context); | ||
} | ||
|
||
async setup() { | ||
await super.setup(); | ||
|
||
// These seem to be needed for @noble/hashes | ||
this.global.TextEncoder = globalThis.TextEncoder; | ||
this.global.TextDecoder = globalThis.TextDecoder; | ||
this.global.Uint8Array = globalThis.Uint8Array; | ||
} | ||
} | ||
|
||
module.exports = CustomizedTestEnvironment; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: '../../customEnv.js', | ||
coverageReporters: ['html', 'lcov', 'json'], | ||
runner: 'groups', | ||
reporters: ['default', 'jest-junit'], | ||
workerThreads: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: '../../customEnv.js', | ||
coverageReporters: ['html', 'lcov', 'json'], | ||
runner: 'groups', | ||
reporters: ['default', 'jest-junit'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: '../../customEnv.js', | ||
coverageReporters: ['html', 'lcov', 'json'], | ||
runner: 'groups', | ||
reporters: ['default', 'jest-junit'], | ||
workerThreads: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: '../../customEnv.js', | ||
testPathIgnorePatterns: [ | ||
'subscriptions', | ||
'tests/utils/poll/event/event-poll.unit.test.ts', | ||
'tests/utils/http/http-client.solo.test.ts', | ||
'http-client.testnet.test.ts' | ||
], | ||
coverageReporters: ['html', 'lcov', 'json'], | ||
runner: 'groups', | ||
reporters: ['default', 'jest-junit'], | ||
workerThreads: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
0179eb7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test Coverage
Summary