diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fba5151..a013b12 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,9 +2,9 @@ name: Test Coveralls on: push: - branches: [ "main" ] + branches: ['main'] pull_request: - branches: [ "main" ] + branches: ['main'] jobs: build: @@ -12,16 +12,17 @@ jobs: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v3 - - uses: actions/checkout@v3 + - name: Use Node.js 18.x + uses: actions/setup-node@v3 + with: + node-version: 18.x + - run: npm ci + - run: npm run build --if-present + - run: npm run test:cov - - name: Use Node.js 18.x - uses: actions/setup-node@v3 - with: - node-version: 18.x - - run: npm ci - - run: npm run build --if-present - - run: npm run test:cov - - - name: Coveralls - uses: coverallsapp/github-action@v2.2.3 \ No newline at end of file + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index a191128..e28eb35 100644 --- a/package.json +++ b/package.json @@ -12,11 +12,11 @@ "start:debug": "nest start --debug --watch", "start:prod": "node dist/src/main", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", - "test": "jest", - "test:watch": "jest --watch", - "test:cov": "jest --coverage --detectOpenHandles --maxWorkers=1", - "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/jest/bin/jest --runInBand", - "test:e2e": "jest --config ./test/jest-e2e.json --passWithNoTests", + "test": "jest --config ./test/jest.config.json", + "test:watch": "npm t -- --watch", + "test:cov": "npm t -- --coverage --detectOpenHandles --maxWorkers=1", + "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/jest/bin/jest --config ./test/jest.config.json --runInBand", + "test:e2e": "jest --config ./test/jest-e2e.config.json --passWithNoTests", "prepare": "husky install", "lint:commit": "commitlint", "typeorm": "typeorm-ts-node-commonjs", @@ -80,30 +80,6 @@ "tsconfig-paths": "^4.2.0", "typescript": "^5.3.3" }, - "jest": { - "moduleFileExtensions": [ - "js", - "json", - "ts" - ], - "rootDir": "./", - "modulePaths": [ - "" - ], - "testRegex": ".*\\.spec\\.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - }, - "collectCoverageFrom": [ - "src/**/*.(t|j)s", - "!**/main.ts", - "!src/core/entities/**", - "!src/core/modules/**", - "!src/common/**" - ], - "coverageDirectory": "../coverage", - "testEnvironment": "node" - }, "contributors": [ { "name": "Olavio Lacerda", diff --git a/test/jest-e2e.json b/test/jest-e2e.config.json similarity index 89% rename from test/jest-e2e.json rename to test/jest-e2e.config.json index 72f1377..4fc8940 100644 --- a/test/jest-e2e.json +++ b/test/jest-e2e.config.json @@ -1,6 +1,6 @@ { "moduleFileExtensions": ["js", "json", "ts"], - "rootDir": ".", + "rootDir": "../", "testEnvironment": "node", "testRegex": "\\.e2e-spec\\.ts$", "transform": { diff --git a/test/jest.config.json b/test/jest.config.json new file mode 100644 index 0000000..de7d5c5 --- /dev/null +++ b/test/jest.config.json @@ -0,0 +1,18 @@ +{ + "moduleFileExtensions": ["js", "json", "ts"], + "rootDir": "../", + "modulePaths": [""], + "testRegex": ".*\\.spec\\.ts$", + "transform": { + "^.+\\.(t|j)s$": "ts-jest" + }, + "collectCoverageFrom": [ + "src/**/*.(t|j)s", + "!**/main.ts", + "!src/core/entities/**", + "!src/core/modules/**", + "!src/common/**" + ], + "coverageDirectory": "./coverage", + "testEnvironment": "node" +}