Skip to content

Commit

Permalink
chore: setup jest with shared config
Browse files Browse the repository at this point in the history
  • Loading branch information
jdabbech-ledger committed Jan 2, 2024
1 parent 6e0586a commit f306cc4
Show file tree
Hide file tree
Showing 17 changed files with 1,705 additions and 183 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: pull_request
on: [pull_request]
jobs:
lint:
test:
runs-on: [device-sdk-4xlarge-linux]
env:
CI_JOB_NUMBER: 1
Expand Down Expand Up @@ -34,5 +34,5 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Lint
run: pnpm lint
- name: Test
run: pnpm test
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
"apps/*"
],
"scripts": {
"build": "turbo build",
"dev": "turbo dev",
"lint": "turbo run lint",
"lint:fix": "turbo run lint:fix",
"build": "turbo build --log-order=grouped",
"dev": "turbo dev --log-order=grouped",
"lint": "turbo run lint --log-order=grouped",
"lint:fix": "turbo run lint:fix --log-order=grouped",
"test": "turbo run test --log-order=grouped",
"core": "turbo --filter @ledgerhq/device-sdk-core",
"signer": "turbo --filter @ledgerhq/device-sdk-signer",
"trusted-apps": "turbo --filter @ledgerhq/device-sdk-trusted-apps",
"ui": "turbo --filter @ledgerhq/device-sdk-ui",
"sample": "turbo --filter @ledgerhq/device-sdk-sample",
"test": "echo \"Error: no test specified\" && exit 1"
"sample": "turbo --filter @ledgerhq/device-sdk-sample"
},
"devDependencies": {
"@ledgerhq/eslint-config-dsdk": "workspace:*",
"@ledgerhq/tsconfig-dsdk": "workspace:*",
"@types/node": "^20.10.6",
"eslint": "^8.56.0",
"jest": "^29.7.0",
"lint-staged": "^15.2.0",
"path": "^0.12.7",
"turbo": "^1.11.2",
"eslint": "^8.56.0",
"typescript": "^5.3.3",
"zx": "^7.2.3"
},
Expand Down
9 changes: 9 additions & 0 deletions packages/config/jest/jest-preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('jest').Config} */
const config = {
preset: "ts-jest",
transform: {
"^.+\\.ts$": "ts-jest",
},
};

module.exports = config;
11 changes: 11 additions & 0 deletions packages/config/jest/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@ledgerhq/jest-config-dsdk",
"version": "1.0.0",
"main": "jest-preset.js",
"types": "node_modules/ts-jest/dist/index.d.ts",
"private": true,
"devDependencies": {
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2"
}
}
2 changes: 1 addition & 1 deletion packages/config/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"devDependencies": {
"@tsconfig/recommended": "^1.0.3",
"@types/eslint": "^8.44.9",
"@types/node": "^20",
"@types/jest": "^29.5.11",
"@types/react": "^18",
"@types/react-dom": "^18"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/config/typescript/sdk.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"target": "esnext",
"lib": ["esnext", "dom"],
"types": ["reflect-metadata"],
"types": ["reflect-metadata", "jest", "node"],
"sourceMap": true,
"declaration": true,
"declarationMap": true,
Expand Down
7 changes: 7 additions & 0 deletions packages/core/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { JestConfigWithTsJest } from "@ledgerhq/jest-config-dsdk";

const config: JestConfigWithTsJest = {
preset: "@ledgerhq/jest-config-dsdk",
};

export default config;
5 changes: 3 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
"lint": "eslint --cache --ext .ts \"src\"",
"lint:fix": "eslint --cache --fix --ext .ts \"src\"",
"feature": "zx scripts/add-feature.mjs",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest --passWithNoTests"
},
"dependencies": {
"inversify": "^6.0.2",
"reflect-metadata": "^0.2.1"
},
"devDependencies": {
"@ledgerhq/eslint-config-dsdk": "workspace:*",
"@ledgerhq/tsconfig-dsdk": "workspace:*"
"@ledgerhq/tsconfig-dsdk": "workspace:*",
"@ledgerhq/jest-config-dsdk": "workspace:*"
}
}
7 changes: 7 additions & 0 deletions packages/signer/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { JestConfigWithTsJest } from "@ledgerhq/jest-config-dsdk";

const config: JestConfigWithTsJest = {
preset: "@ledgerhq/jest-config-dsdk",
};

export default config;
5 changes: 3 additions & 2 deletions packages/signer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
"dev": "tsc --watch",
"lint": "eslint --cache --ext .ts \"src\"",
"lint:fix": "eslint --cache --fix --ext .ts \"src\"",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest --passWithNoTests"
},
"dependencies": {
"inversify": "^6.0.2",
"reflect-metadata": "^0.2.1"
},
"devDependencies": {
"@ledgerhq/tsconfig-dsdk": "workspace:*",
"@ledgerhq/eslint-config-dsdk": "workspace:*"
"@ledgerhq/eslint-config-dsdk": "workspace:*",
"@ledgerhq/jest-config-dsdk": "workspace:*"
}
}
7 changes: 7 additions & 0 deletions packages/signer/tests/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Hello } from "../src";

describe("signer", () => {
it("should be Hello World", () => {
expect(Hello).toEqual("World");
});
});
7 changes: 7 additions & 0 deletions packages/trusted-apps/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { JestConfigWithTsJest } from "@ledgerhq/jest-config-dsdk";

const config: JestConfigWithTsJest = {
preset: "@ledgerhq/jest-config-dsdk",
};

export default config;
5 changes: 3 additions & 2 deletions packages/trusted-apps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
"lint": "eslint --cache --ext .ts \"src\"",
"lint:fix": "eslint --cache --fix --ext .ts \"src\"",
"dev": "tsc --watch",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest --passWithNoTests"
},
"dependencies": {
"inversify": "^6.0.2",
"reflect-metadata": "^0.2.1"
},
"devDependencies": {
"@ledgerhq/tsconfig-dsdk": "workspace:*",
"@ledgerhq/eslint-config-dsdk": "workspace:*"
"@ledgerhq/eslint-config-dsdk": "workspace:*",
"@ledgerhq/jest-config-dsdk": "workspace:*"
}
}
7 changes: 7 additions & 0 deletions packages/ui/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { JestConfigWithTsJest } from "@ledgerhq/jest-config-dsdk";

const config: JestConfigWithTsJest = {
preset: "@ledgerhq/jest-config-dsdk",
};

export default config;
5 changes: 3 additions & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
"dev": "tsc --watch",
"lint": "eslint --cache --ext .ts \"src\"",
"lint:fix": "eslint --cache --fix --ext .ts \"src\"",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest --passWithNoTests"
},
"dependencies": {
"inversify": "^6.0.2",
"reflect-metadata": "^0.2.1"
},
"devDependencies": {
"@ledgerhq/tsconfig-dsdk": "workspace:*",
"@ledgerhq/eslint-config-dsdk": "workspace:*"
"@ledgerhq/eslint-config-dsdk": "workspace:*",
"@ledgerhq/jest-config-dsdk": "workspace:*"
}
}
Loading

0 comments on commit f306cc4

Please sign in to comment.