refactor jest setup to improve unit/integration test executions (#2322)

* fix test:integration command to run tests directly under ./test/integration

* refactor jest setup to have separate config files for integration and unit tests
This commit is contained in:
Omar Khan
2023-05-26 15:16:44 -04:00
committed by GitHub
parent 82c5b3598a
commit 70a9ab0510
6 changed files with 20 additions and 10 deletions

View File

@@ -4,5 +4,9 @@ const base = require('../../jest.config.base.js')
module.exports = {
...base,
roots: [...base.roots, '<rootDir>/test'],
testMatch: [
'<rootDir>/test/integration/**/*.test.ts',
'<rootDir>/test/integration/*.test.ts',
],
displayName: 'xrpl.js',
}

View File

@@ -0,0 +1,13 @@
// Jest configuration for api
const base = require('../../jest.config.base.js')
module.exports = {
...base,
roots: [...base.roots, '<rootDir>/test'],
testMatch: ['<rootDir>/test/**/*.test.ts'],
testPathIgnorePatterns: [
'<rootDir>/test/integration',
'<rootDir>/test/fixtures',
],
displayName: 'xrpl.js',
}

View File

@@ -61,8 +61,8 @@
"clean": "rm -rf dist build coverage",
"docgen": "tsc --build tsconfig.docs.json && typedoc && echo js.xrpl.org >> ../../docs/CNAME",
"prepublish": "npx run-s clean build",
"test": "jest --verbose false --silent=false ./test/**/*.test.ts --testPathIgnorePatterns=./test/integration --testPathIgnorePatterns=./test/fixtures",
"test:integration": "TS_NODE_PROJECT=tsconfig.build.json jest --verbose false --silent=false --runInBand ./test/integration/**/*.test.ts",
"test": "jest --config=jest.config.unit.js --verbose false --silent=false",
"test:integration": "TS_NODE_PROJECT=tsconfig.build.json jest --config=jest.config.integration.js --verbose false --silent=false --runInBand",
"test:browser": "npm run build && npm run build:browserTests && karma start ./karma.config.js --single-run",
"test:watch": "jest --watch --verbose false --silent=false --runInBand ./test/**/*.test.ts --testPathIgnorePatterns=./test/integration --testPathIgnorePatterns=./test/fixtures",
"format": "prettier --write '{src,test}/**/*.ts'",

View File

@@ -437,6 +437,7 @@ describe('Connection', function () {
try {
await clientContext.client.connect()
} catch (error) {
// @ts-expect-error -- error.message is expected to be defined
expect(error.message).toEqual(
"Error: connect() timed out after 5000 ms. If your internet connection is working, the rippled server may be blocked or inaccessible. You can also try setting the 'connectionTimeout' option in the Client constructor.",
)

View File

@@ -49,7 +49,6 @@ export * from './integration.test'
export * from './onConnect.test'
export * from './regularKey.test'
export * from './submitAndWait.test'
export * from './wallet.test'
// Because this does 256 ledger accepts, we do it last
export * from './transactions/accountDelete.test'

View File

@@ -1,7 +0,0 @@
import { Wallet } from '../../src'
const walletSecret = 'shK6YXzwYfnFVn3YZSaMh5zuAddKx'
const wallet = Wallet.fromSeed(walletSecret)
export default wallet