Skip to content

Commit

Permalink
Merge pull request #71 from jordanshatford/feat/jest-to-vitests
Browse files Browse the repository at this point in the history
chore(deps): replace jest with vitest
  • Loading branch information
mrlubos authored Mar 20, 2024
2 parents 13f26e6 + 625a8c2 commit fc3ea9a
Show file tree
Hide file tree
Showing 67 changed files with 10,128 additions and 13,413 deletions.
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
],
"env": {
"es6": true,
"jest": true,
"node": true
},
"plugins": ["simple-import-sort"],
Expand Down
18 changes: 0 additions & 18 deletions babel.config.json

This file was deleted.

43 changes: 0 additions & 43 deletions jest.config.ts

This file was deleted.

14,124 changes: 5,674 additions & 8,450 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 7 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
"lint:fix": "eslint . --fix",
"lint": "eslint .",
"prepublishOnly": "npm run build",
"test": "jest --selectProjects UNIT",
"test:coverage": "jest --selectProjects UNIT --coverage",
"test:e2e": "jest --selectProjects E2E --runInBand --verbose",
"test": "vitest run --config vitest.config.unit.ts",
"test:update": "vitest run --config vitest.config.unit.ts --update",
"test:coverage": "vitest run --config vitest.config.unit.ts --coverage",
"test:watch": "vitest --config vitest.config.unit.ts --watch",
"test:e2e": "vitest run --config vitest.config.e2e.ts",
"test:sample": "node test/sample.cjs",
"test:update": "jest --selectProjects UNIT --updateSnapshot",
"test:watch": "jest --selectProjects UNIT --watch",
"typecheck": "tsc --noEmit"
},
"engines": {
Expand All @@ -82,22 +82,18 @@
"@angular/platform-browser": "17.0.8",
"@angular/platform-browser-dynamic": "17.0.8",
"@angular/router": "17.0.8",
"@babel/cli": "7.23.9",
"@babel/core": "7.23.9",
"@babel/preset-env": "7.23.9",
"@babel/preset-typescript": "7.23.3",
"@rollup/plugin-commonjs": "25.0.7",
"@rollup/plugin-json": "6.1.0",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-terser": "0.4.4",
"@rollup/plugin-typescript": "11.1.6",
"@types/cross-spawn": "6.0.6",
"@types/express": "4.17.21",
"@types/jest": "29.5.12",
"@types/node": "20.11.17",
"@types/qs": "6.9.11",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"@vitest/coverage-v8": "1.4.0",
"abort-controller": "3.0.0",
"axios": "1.6.7",
"cross-spawn": "7.0.3",
Expand All @@ -107,9 +103,6 @@
"eslint-plugin-simple-import-sort": "10.0.0",
"express": "4.18.2",
"form-data": "4.0.0",
"glob": "10.3.10",
"jest": "29.7.0",
"jest-cli": "29.7.0",
"npm-run-all2": "6.1.2",
"prettier": "3.2.5",
"puppeteer": "22.4.1",
Expand All @@ -121,6 +114,7 @@
"ts-node": "10.9.2",
"tslib": "2.6.2",
"typescript": "5.2.2",
"vitest": "1.4.0",
"zone.js": "0.14.3"
},
"packageManager": "npm@10.5.0+sha256.17ca6e08e7633b624e8f870db81a78f46afe119de62bcaf0a7407574139198fc"
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { defineConfig } from 'rollup';
* the template on the fly. This reduces runtime by about
* half on large projects.
*/
function handlebarsPlugin(): Plugin {
export function handlebarsPlugin(): Plugin {
return {
name: 'handlebars',
resolveId: (file: any, importer: any) => {
Expand Down
8 changes: 5 additions & 3 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { afterEach, describe, expect, it, vi } from 'vitest';

import { createClient, parseOpenApiSpecification } from './index';
import * as parseV2 from './openApi/v2';
import * as parseV3 from './openApi/v3';
Expand Down Expand Up @@ -38,7 +40,7 @@ describe('index', () => {

describe('parseOpenApiSpecification', () => {
afterEach(() => {
jest.restoreAllMocks();
vi.restoreAllMocks();
});

const options: Parameters<typeof parseOpenApiSpecification>[1] = {
Expand All @@ -62,7 +64,7 @@ describe('parseOpenApiSpecification', () => {
};

it('uses v2 parser', () => {
const spy = jest.spyOn(parseV2, 'parse');
const spy = vi.spyOn(parseV2, 'parse');

const spec: Parameters<typeof parseOpenApiSpecification>[0] = {
info: {
Expand All @@ -88,7 +90,7 @@ describe('parseOpenApiSpecification', () => {
});

it('uses v3 parser', () => {
const spy = jest.spyOn(parseV3, 'parse');
const spy = vi.spyOn(parseV3, 'parse');

const spec: Parameters<typeof parseOpenApiSpecification>[0] = {
info: {
Expand Down
2 changes: 2 additions & 0 deletions src/openApi/v2/parser/getModelTemplate.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getModelTemplate } from './getModelTemplate';

describe('getModelTemplate', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/openApi/v2/parser/getOperationParameterName.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getOperationParameterName } from './getOperationParameterName';

describe('getOperationParameterName', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/openApi/v2/parser/getOperationResponseCode.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getOperationResponseCode } from './getOperationResponseCode';

describe('getOperationResponseCode', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/openApi/v2/parser/getRef.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getRef } from './getRef';

describe('getRef', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/openApi/v2/parser/getServer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getServer } from './getServer';

describe('getServer', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/openApi/v2/parser/getServiceName.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getServiceName } from './getServiceName';

describe('getServiceName', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/openApi/v2/parser/getServiceVersion.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getServiceVersion } from './getServiceVersion';

describe('getServiceVersion', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/openApi/v2/parser/getServices.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getServices } from './getServices';

describe('getServices', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/openApi/v3/parser/__tests__/getServices.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getServices } from '../getServices';

describe('getServices', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/openApi/v3/parser/__tests__/service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getServiceName, getServiceVersion } from '../service';

describe('getServiceName', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/openApi/v3/parser/getModel.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { reservedWords } from '../../../utils/reservedWords';
import { getType } from '../../../utils/type';
import { getModel } from './getModel';
Expand Down
2 changes: 2 additions & 0 deletions src/openApi/v3/parser/getModelTemplate.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getModelTemplate } from './getModelTemplate';

describe('getModelTemplate', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/openApi/v3/parser/getOperationParameterName.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getOperationParameterName } from './getOperationParameterName';

describe('getOperationParameterName', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/openApi/v3/parser/getOperationResponseCode.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getOperationResponseCode } from './getOperationResponseCode';

describe('getOperationResponseCode', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/openApi/v3/parser/getRef.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getRef } from './getRef';

describe('getRef', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/openApi/v3/parser/getServer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getServer } from './getServer';

describe('getServer', () => {
Expand Down
6 changes: 0 additions & 6 deletions src/utils/__mocks__/fileSystem.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/utils/__tests__/enum.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { enumKey } from '../enum';

describe('enumKey', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/__tests__/escapeName.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { escapeName, unescapeName } from '../escapeName';

const data = [
Expand Down
1 change: 1 addition & 0 deletions src/utils/__tests__/handlebars.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Handlebars from 'handlebars/runtime';
import { describe, expect, it } from 'vitest';

import { registerHandlebarHelpers, registerHandlebarTemplates } from '../handlebars';

Expand Down
2 changes: 2 additions & 0 deletions src/utils/__tests__/operation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getOperationName } from '../operation';

describe('getOperationName', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/__tests__/sortByName.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import type { Model } from '../../client/interfaces/Model';
import type { Service } from '../../client/interfaces/Service';
import { sortByName } from '../sortByName';
Expand Down
2 changes: 2 additions & 0 deletions src/utils/__tests__/stripNamespace.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { stripNamespace } from '../stripNamespace';

describe('stripNamespace', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/__tests__/type.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getMappedType, getType } from '../type';

describe('getMappedType', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/getPattern.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getPattern } from './getPattern';

describe('getPattern', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/isSubdirectory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import path from 'node:path';

import { describe, expect, it } from 'vitest';

import { isSubDirectory } from './isSubdirectory';

describe('isSubDirectory', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/sanitizeTypeName.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import sanitizeTypeName from './sanitizeTypeName';

describe('sanitizeTypeName', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/sort.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { sort } from './sort';

describe('sort', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/unique.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { unique } from './unique';

describe('unique', () => {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/write/__tests__/class.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { writeFileSync } from 'node:fs';

import { describe, expect, it, vi } from 'vitest';

import { writeClientClass } from '../class';

jest.mock('node:fs');
vi.mock('node:fs');

describe('writeClientClass', () => {
it('should write to filesystem', async () => {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/write/__tests__/client.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { mkdirSync, rmSync, writeFileSync } from 'node:fs';

import { describe, expect, it, vi } from 'vitest';

import { writeClient } from '../client';

jest.mock('node:fs');
vi.mock('node:fs');

describe('writeClient', () => {
it('should write to filesystem', async () => {
Expand Down
6 changes: 4 additions & 2 deletions src/utils/write/__tests__/core.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { writeFileSync } from 'node:fs';
import path from 'node:path';

import { beforeEach, describe, expect, it, vi } from 'vitest';

import { writeClientCore } from '../core';

jest.mock('node:fs');
vi.mock('node:fs');

describe('writeClientCore', () => {
let templates: Parameters<typeof writeClientCore>[1];
Expand All @@ -18,7 +20,7 @@ describe('writeClientCore', () => {
cancelablePromise: () => 'cancelablePromise',
httpRequest: () => 'httpRequest',
request: () => 'request',
settings: jest.fn().mockReturnValue('settings'),
settings: vi.fn().mockReturnValue('settings'),
types: () => 'types',
},
exports: {
Expand Down
Loading

0 comments on commit fc3ea9a

Please sign in to comment.