Skip to content

Commit

Permalink
chore: Use jest in create-lz-oapp
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista committed Dec 8, 2023
1 parent bdcd719 commit f203f82
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 79 deletions.
5 changes: 0 additions & 5 deletions packages/create-lz-oapp/.mocharc.json

This file was deleted.

17 changes: 17 additions & 0 deletions packages/create-lz-oapp/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testTimeout: 15000,
moduleNameMapper: {
"^@/(.*)\\.js$": "<rootDir>/src/$1",
},
transform: {
// ts-jest does not yet work great with node16 module resolution
// so we need to help it a little
//
// See https://github.com/kulshekhar/ts-jest/issues/4207 for the issue
// And https://github.com/kulshekhar/ts-jest/issues/4198 for another one
"^.+\\.tsx?$": ["ts-jest", { tsconfig: "tsconfig.test.json" }],
},
};
8 changes: 4 additions & 4 deletions packages/create-lz-oapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,18 @@
"dev": "npx tsup --watch",
"lint": "npx eslint '**/*.{js,ts,json}'",
"start": "./cli.cjs",
"test": "mocha --parallel"
"test": "jest --config jest.config.cjs"
},
"dependencies": {
"yoga-wasm-web": "~0.3.3"
},
"devDependencies": {
"@layerzerolabs/io-utils": "~0.0.1",
"@tanstack/react-query": "^5.8.4",
"@types/mocha": "^10.0.6",
"@types/jest": "^29.5.10",
"@types/prompts": "^2.4.9",
"@types/react": "^18.2.38",
"@types/which": "~3.0.3",
"chai": "^4.3.10",
"commander": "^11.1.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
Expand All @@ -48,11 +47,12 @@
"ink-select-input": "^5.0.0",
"ink-spinner": "^5.0.0",
"ink-text-input": "^5.0.1",
"mocha": "^10.0.0",
"jest": "^29.7.0",
"prompts": "^2.4.2",
"react": "^18.2.0",
"react-devtools-core": "^4.28.5",
"tiged": "^2.12.5",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"which": "~4.0.0"
Expand Down
24 changes: 11 additions & 13 deletions packages/create-lz-oapp/test/utilities/cloning.test.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
import { expect } from 'chai'
import { describe, it } from 'mocha'
import { createExampleGitURL } from '../../src/utilities/cloning.js'
import { createExampleGitURL } from '@/utilities/cloning.js'

describe('utilities/cloning', () => {
describe('createExampleGitURL', () => {
const REPO_URL = '[email protected]:LayerZero-Labs/lz-utils'

it('should return the repository field if directory and ref are not specified', () => {
expect(createExampleGitURL({ repository: REPO_URL, id: 'dummy', label: 'Dummy' })).to.eql(REPO_URL)
expect(createExampleGitURL({ repository: REPO_URL, id: 'dummy', label: 'Dummy' })).toEqual(REPO_URL)
})

it('should return the repository field with directory if directory is specified', () => {
expect(createExampleGitURL({ repository: REPO_URL, directory: 'dir', id: 'dummy', label: 'Dummy' })).to.eql(
`${REPO_URL}/dir`
)
expect(
createExampleGitURL({ repository: REPO_URL, directory: 'dir', id: 'dummy', label: 'Dummy' })
).toEqual(`${REPO_URL}/dir`)
expect(
createExampleGitURL({ repository: REPO_URL, directory: '/dir', id: 'dummy', label: 'Dummy' })
).to.eql(`${REPO_URL}/dir`)
).toEqual(`${REPO_URL}/dir`)
expect(
createExampleGitURL({ repository: REPO_URL, directory: 'dir', ref: '', id: 'dummy', label: 'Dummy' })
).to.eql(`${REPO_URL}/dir`)
).toEqual(`${REPO_URL}/dir`)
})

it('should return the repository field with directory and ref if directory and ref are specified', () => {
expect(
createExampleGitURL({ repository: REPO_URL, directory: 'dir', ref: 'ref', id: 'dummy', label: 'Dummy' })
).to.eql(`${REPO_URL}/dir#ref`)
).toEqual(`${REPO_URL}/dir#ref`)
expect(
createExampleGitURL({
repository: REPO_URL,
Expand All @@ -34,14 +32,14 @@ describe('utilities/cloning', () => {
id: 'dummy',
label: 'Dummy',
})
).to.eql(`${REPO_URL}/dir#ref`)
).toEqual(`${REPO_URL}/dir#ref`)
})

it('should return the repository field with ref if only ref specified', () => {
expect(createExampleGitURL({ repository: REPO_URL, ref: 'ref', id: 'dummy', label: 'Dummy' })).to.eql(
expect(createExampleGitURL({ repository: REPO_URL, ref: 'ref', id: 'dummy', label: 'Dummy' })).toEqual(
`${REPO_URL}#ref`
)
expect(createExampleGitURL({ repository: REPO_URL, ref: '#ref', id: 'dummy', label: 'Dummy' })).to.eql(
expect(createExampleGitURL({ repository: REPO_URL, ref: '#ref', id: 'dummy', label: 'Dummy' })).toEqual(
`${REPO_URL}#ref`
)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/create-lz-oapp/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lib": ["dom", "dom.Iterable", "es2022"],
"resolveJsonModule": false,
"target": "esnext",
"types": ["mocha", "node"],
"types": ["jest", "node"],
"paths": {
"@/*": ["./src/*"]
}
Expand Down
7 changes: 7 additions & 0 deletions packages/create-lz-oapp/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Node10"
}
}
2 changes: 1 addition & 1 deletion packages/utils-evm-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"scripts": {
"lint": "npx eslint '**/*.{js,ts,json}'",
"pretest": "npx hardhat compile",
"test": "jest --pasWithNoTests"
"test": "jest --passWithNoTests"
},
"devDependencies": {
"@ethersproject/abi": "^5.7.0",
Expand Down
56 changes: 1 addition & 55 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2731,11 +2731,6 @@
resolved "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.5.tgz"
integrity sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==

"@types/mocha@^10.0.6":
version "10.0.6"
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-10.0.6.tgz#818551d39113081048bdddbef96701b4e8bb9d1b"
integrity sha512-dJvrYWxP/UcXm36Qn36fxhUKu8A/xMRXVT2cliFF1Z7UA9liG5Psj3ezNSZw+5puH2czDXRLcXQxf8JbJt0ejg==

"@types/mute-stream@^0.0.4":
version "0.0.4"
resolved "https://registry.yarnpkg.com/@types/mute-stream/-/mute-stream-0.0.4.tgz#77208e56a08767af6c5e1237be8888e2f255c478"
Expand Down Expand Up @@ -3424,11 +3419,6 @@ [email protected], assert-plus@^1.0.0:
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525"
integrity sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==

assertion-error@^1.1.0:
version "1.1.0"
resolved "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz"
integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==

ast-parents@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/ast-parents/-/ast-parents-0.0.1.tgz#508fd0f05d0c48775d9eccda2e174423261e8dd3"
Expand Down Expand Up @@ -4067,19 +4057,6 @@ catering@^2.1.0, catering@^2.1.1:
resolved "https://registry.npmjs.org/catering/-/catering-2.1.1.tgz"
integrity sha512-K7Qy8O9p76sL3/3m7/zLKbRkyOlSZAgzEaLhyj2mXS8PsCud2Eo4hAb8aLtZqHh0QGqLcb9dlJSu6lHRVENm1w==

chai@^4.3.10:
version "4.3.10"
resolved "https://registry.npmjs.org/chai/-/chai-4.3.10.tgz"
integrity sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==
dependencies:
assertion-error "^1.1.0"
check-error "^1.0.3"
deep-eql "^4.1.3"
get-func-name "^2.0.2"
loupe "^2.3.6"
pathval "^1.1.1"
type-detect "^4.0.8"

[email protected], chalk@^5.2.0:
version "5.3.0"
resolved "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz"
Expand Down Expand Up @@ -4112,13 +4089,6 @@ chardet@^0.7.0:
resolved "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz"
integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==

check-error@^1.0.3:
version "1.0.3"
resolved "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz"
integrity sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==
dependencies:
get-func-name "^2.0.2"

checkpoint-store@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/checkpoint-store/-/checkpoint-store-1.1.0.tgz#04e4cb516b91433893581e6d4601a78e9552ea06"
Expand Down Expand Up @@ -4734,13 +4704,6 @@ dedent@^1.0.0:
resolved "https://registry.yarnpkg.com/dedent/-/dedent-1.5.1.tgz#4f3fc94c8b711e9bb2800d185cd6ad20f2a90aff"
integrity sha512-+LxW+KLWxu3HW3M2w2ympwtqPrqYRzU8fqi6Fhd18fBALe15blJPI/I4+UHveMVG6lJqB4JNd4UG0S5cnVHwIg==

deep-eql@^4.1.3:
version "4.1.3"
resolved "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz"
integrity sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==
dependencies:
type-detect "^4.0.0"

deep-extend@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac"
Expand Down Expand Up @@ -6467,11 +6430,6 @@ get-caller-file@^2.0.1, get-caller-file@^2.0.5:
resolved "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz"
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==

get-func-name@^2.0.1, get-func-name@^2.0.2:
version "2.0.2"
resolved "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz"
integrity sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==

get-intrinsic@^1.0.2, get-intrinsic@^1.1.3:
version "1.2.1"
resolved "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz"
Expand Down Expand Up @@ -8551,13 +8509,6 @@ loose-envify@^1.1.0, loose-envify@^1.4.0:
dependencies:
js-tokens "^3.0.0 || ^4.0.0"

loupe@^2.3.6:
version "2.3.7"
resolved "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz"
integrity sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==
dependencies:
get-func-name "^2.0.1"

lowercase-keys@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479"
Expand Down Expand Up @@ -9579,11 +9530,6 @@ path-type@^4.0.0:
resolved "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz"
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==

pathval@^1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz"
integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==

pbkdf2@^3.0.17:
version "3.1.2"
resolved "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.2.tgz"
Expand Down Expand Up @@ -11428,7 +11374,7 @@ type-check@^0.4.0, type-check@~0.4.0:
dependencies:
prelude-ls "^1.2.1"

[email protected], type-detect@^4.0.0, type-detect@^4.0.8:
[email protected], type-detect@^4.0.8:
version "4.0.8"
resolved "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz"
integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==
Expand Down

0 comments on commit f203f82

Please sign in to comment.