Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:

steps:
- name: 🗜️ Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: 🗜️ Setup node version
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
Expand All @@ -27,10 +27,10 @@ jobs:
run: yarn build

- name: 🧪 Run tests
run: yarn test --collectCoverage --ci
run: yarn test --coverage --run

- name: ⬆️ Upload coverage reports
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
fail_ci_if_error: true
Expand All @@ -56,7 +56,7 @@ jobs:

- name: 🛠️ Use GPR
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, 'beta') == false
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: 22
registry-url: https://npm.pkg.github.com/
Expand Down
29 changes: 10 additions & 19 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:

steps:
- name: 🗜️ Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: 🗜️ Setup node version
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
Expand All @@ -23,27 +23,18 @@ jobs:
run: yarn build

- name: 🧪 Run tests
run: npx jest --ci --json --coverage --testLocationInResults --outputFile=coverage/report.json
run: yarn test --coverage --run

- name: 🧪 Create coverage report markdown
uses: ArtiomTr/jest-coverage-report-action@v2
id: coverage
- name: 🧪 Create coverage report
uses: davelosert/vitest-coverage-report-action@v2
if: always()
with:
prnumber: ${{ steps.findPr.outputs.number }}
coverage-file: coverage/report.json
package-manager: yarn
custom-title: 🧪 Unit tests
threshold: 80
skip-step: all
output: report-markdown

- name: 💬 Create coverage report comment
uses: marocchino/sticky-pull-request-comment@v2
with:
message: ${{ steps.coverage.outputs.report }}
vite-config-path: ./vitest.config.ts
json-summary-path: ./coverage/coverage-summary.json
json-final-path: ./coverage/coverage-final.json

- name: ⬆️ Upload coverage reports
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
fail_ci_if_error: true
Expand Down
16 changes: 0 additions & 16 deletions jest.config.ts

This file was deleted.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"demo": "yarn tsx ./demo.ts",
"build": "rimraf dist && tsc --build tsconfig.es6.json && tsc --build tsconfig.es5.json",
"postbuild": "copyfiles ./package.json ./README.md ./LICENSE ./dist && yarn prepare-dist",
"test": "jest",
"test": "vitest run",
"husky:install": "husky",
"prepare-source": "yarn tsx ./scripts/prepare-source.ts",
"prepare-dist": "yarn tsx ./scripts/prepare-dist.ts",
Expand Down Expand Up @@ -50,23 +50,22 @@
"@commitlint/cli": "^20.5.3",
"@commitlint/config-conventional": "^20.5.3",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^30.0.0",
"@typescript-eslint/eslint-plugin": "^8.48.1",
"@typescript-eslint/parser": "^8.48.1",
"@vitest/coverage-v8": "^4.1.5",
"auto-changelog": "^2.5.0",
"copyfiles": "^2.4.1",
"eslint": "^9.39.1",
"fs-extra": "^11.3.4",
"husky": "^9.1.7",
"jest": "^30.3.0",
"prettier": "^3.8.3",
"pretty-quick": "^4.2.2",
"rimraf": "^6.1.3",
"ts-jest": "^29.4.9",
"ts-node": "^10.9.2",
"tsc-watch": "^6.2.0",
"tsx": "^4.21.0",
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"vitest": "^4.1.5"
},
"keywords": [
"data",
Expand Down
3 changes: 2 additions & 1 deletion test/client/eurofotbal.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { vi } from 'vitest';
import { SoccerBotEurofotbalClient } from '../../src/clients/eurofotbal';
import { TEAM_DATA, TEAM_HTML } from '../mocks/eurofotbal/team';

Expand All @@ -10,7 +11,7 @@ describe('SoccerBotEurofotbalClient', () => {

describe('team', () => {
beforeEach(() => {
const handleSpy = jest.spyOn(SoccerBotEurofotbalClient.prototype as any, 'fetchPage');
const handleSpy = vi.spyOn(SoccerBotEurofotbalClient.prototype as any, 'fetchPage');
handleSpy.mockImplementation(() => {
return new Promise((resolve) => {
resolve(TEAM_HTML);
Expand Down
5 changes: 3 additions & 2 deletions test/client/fotbalunas.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { vi } from 'vitest';
import { SoccerBotFotbalunasClient } from '../../src/clients/fotbalunas';
import { LEAGUE_DATA, LEAGUE_HTML } from '../mocks/fotbalunas/league';
import { CLUB_HTML, TEAM_DATA, TEAM_HTML } from '../mocks/fotbalunas/team';
Expand Down Expand Up @@ -35,7 +36,7 @@ describe('SoccerBotFotbalunasClient', () => {

describe('league', () => {
beforeEach(() => {
const handleSpy = jest.spyOn(SoccerBotFotbalunasClient.prototype as any, 'fetchPage');
const handleSpy = vi.spyOn(SoccerBotFotbalunasClient.prototype as any, 'fetchPage');
handleSpy.mockImplementation(() => {
return new Promise((resolve) => {
resolve(LEAGUE_HTML);
Expand All @@ -50,7 +51,7 @@ describe('SoccerBotFotbalunasClient', () => {

describe('team', () => {
beforeEach(() => {
const handleSpy = jest.spyOn(SoccerBotFotbalunasClient.prototype as any, 'fetchPage');
const handleSpy = vi.spyOn(SoccerBotFotbalunasClient.prototype as any, 'fetchPage');
handleSpy
.mockImplementationOnce(() => {
return new Promise((resolve) => {
Expand Down
9 changes: 5 additions & 4 deletions test/client/soccerway.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { vi } from 'vitest';
import { SoccerBotSoccerwayClient } from '../../src/clients/soccerway';
import { LEAGUE_DATA, LEAGUE_HTML } from '../mocks/soccerway/league';
import { PLAYER_DATA, PLAYER_HTML } from '../mocks/soccerway/player';
Expand Down Expand Up @@ -58,7 +59,7 @@ describe('SoccerBotSoccerwayClient', () => {

describe('league', () => {
beforeEach(() => {
const handleSpy = jest.spyOn(SoccerBotSoccerwayClient.prototype as any, 'fetchPage');
const handleSpy = vi.spyOn(SoccerBotSoccerwayClient.prototype as any, 'fetchPage');
handleSpy.mockImplementation(() => {
return new Promise((resolve) => {
resolve(LEAGUE_HTML);
Expand All @@ -73,14 +74,14 @@ describe('SoccerBotSoccerwayClient', () => {

describe('team', () => {
beforeEach(() => {
const handleSpy = jest.spyOn(SoccerBotSoccerwayClient.prototype as any, 'fetchPage');
const handleSpy = vi.spyOn(SoccerBotSoccerwayClient.prototype as any, 'fetchPage');
handleSpy.mockImplementation(() => {
return new Promise((resolve) => {
resolve(TEAM_HTML);
});
});

const handlePlayerSpy = jest.spyOn(SoccerBotSoccerwayClient.prototype as any, 'player');
const handlePlayerSpy = vi.spyOn(SoccerBotSoccerwayClient.prototype as any, 'player');
handlePlayerSpy.mockImplementation(() => {
return new Promise((resolve) => {
resolve(PLAYER_DATA);
Expand All @@ -95,7 +96,7 @@ describe('SoccerBotSoccerwayClient', () => {

describe('player', () => {
beforeEach(() => {
const handleSpy = jest.spyOn(SoccerBotSoccerwayClient.prototype as any, 'fetchPage');
const handleSpy = vi.spyOn(SoccerBotSoccerwayClient.prototype as any, 'fetchPage');
handleSpy.mockImplementation(() => {
return new Promise((resolve) => {
resolve(PLAYER_HTML);
Expand Down
10 changes: 5 additions & 5 deletions test/client/sportnet.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { vi } from 'vitest';
import { SoccerBotSportnetClient } from '../../src/clients/sportnet';
import { SoccerBotPlayer, SoccerBotPositionGroup, SoccerBotResponse } from '../../src/shared/interfaces';
import { LEAGUE_DATA, LEAGUE_HTML } from '../mocks/sportnet/league';
Expand Down Expand Up @@ -51,7 +52,7 @@ describe('SoccerBotSportnetClient', () => {

describe('league', () => {
beforeEach(() => {
const handleSpy = jest.spyOn(SoccerBotSportnetClient.prototype as any, 'fetchPage');
const handleSpy = vi.spyOn(SoccerBotSportnetClient.prototype as any, 'fetchPage');
handleSpy.mockImplementation(() => {
return new Promise((resolve) => {
resolve(LEAGUE_HTML);
Expand All @@ -66,14 +67,13 @@ describe('SoccerBotSportnetClient', () => {

describe('team', () => {
beforeEach(() => {
jest.spyOn(SoccerBotSportnetClient.prototype as any, 'player').mockImplementation(() => {
vi.spyOn(SoccerBotSportnetClient.prototype as any, 'player').mockImplementation(() => {
return new Promise((resolve) => {
resolve(PLAYER_DATA);
});
});

jest
.spyOn(SoccerBotSportnetClient.prototype as any, 'fetchPage')
vi.spyOn(SoccerBotSportnetClient.prototype as any, 'fetchPage')
.mockImplementationOnce(() => {
return new Promise((resolve) => {
resolve(TEAM_HTML);
Expand Down Expand Up @@ -106,7 +106,7 @@ describe('SoccerBotSportnetClient', () => {

describe('player', () => {
beforeEach(() => {
const handleSpy = jest.spyOn(SoccerBotSportnetClient.prototype as any, 'fetchPage');
const handleSpy = vi.spyOn(SoccerBotSportnetClient.prototype as any, 'fetchPage');
handleSpy.mockImplementation(() => {
return new Promise((resolve) => {
resolve(PLAYER_HTML);
Expand Down
5 changes: 3 additions & 2 deletions test/client/transfermarkt.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { vi } from 'vitest';
import { SoccerBotTransfermarktClient } from '../../src/clients/transfermarkt';
import { LEAGUE_DATA, LEAGUE_HTML } from '../mocks/transfermarkt/league';
import { TEAM_DATA, TEAM_HTML } from '../mocks/transfermarkt/team';
Expand Down Expand Up @@ -43,7 +44,7 @@ describe('SoccerBotTransfermarktClient', () => {

describe('league', () => {
beforeEach(() => {
const handleSpy = jest.spyOn(SoccerBotTransfermarktClient.prototype as any, 'fetchPage');
const handleSpy = vi.spyOn(SoccerBotTransfermarktClient.prototype as any, 'fetchPage');
handleSpy.mockImplementation(() => {
return new Promise((resolve) => {
resolve(LEAGUE_HTML);
Expand All @@ -58,7 +59,7 @@ describe('SoccerBotTransfermarktClient', () => {

describe('team', () => {
beforeEach(() => {
const handleSpy = jest.spyOn(SoccerBotTransfermarktClient.prototype as any, 'fetchPage');
const handleSpy = vi.spyOn(SoccerBotTransfermarktClient.prototype as any, 'fetchPage');
handleSpy.mockImplementation(() => {
return new Promise((resolve) => {
resolve(TEAM_HTML);
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"target": "es2019",
"lib": ["dom"],
"types": ["node", "jest"],
"types": ["node", "vitest/globals"],
"baseUrl": "./src",
"esModuleInterop": true,
"module": "commonjs",
Expand Down
14 changes: 14 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
globals: true,
include: ['**/*.spec.ts'],
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'json-summary', 'html', 'lcov'],
reportsDirectory: 'coverage'
},
testTimeout: 20000
}
});
Loading
Loading