Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change to new typeschema package #46

Merged
merged 4 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test: use vite for typeschema and update tests
  • Loading branch information
jmcdo29 committed Aug 21, 2024
commit 4bd9f225c09216acd3bdf8c52038911b471c4429
4 changes: 4 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
"codeCoverage": true
}
}
},
"@nx/vite:test": {
"cache": true,
"inputs": ["default", "^production"]
}
},
"nxCloudAccessToken": "",
Expand Down
33 changes: 27 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"private": true,
"devDependencies": {
"$lib": "link:@typeschema/$lib",
"@changesets/cli": "^2.23.2",
"@nestjs/common": "10.0.3",
"@nestjs/core": "10.0.3",
Expand All @@ -40,18 +41,35 @@
"@nx/jest": "19.6.1",
"@nx/js": "19.6.1",
"@nx/nest": "19.6.1",
"@nx/vite": "^19.6.1",
"@nx/web": "19.6.1",
"@nx/workspace": "19.6.1",
"@sinclair/typebox": "^0.31.14",
"@swc-node/register": "~1.9.1",
"@swc/core": "1.5.7",
"@swc/helpers": "~0.5.11",
"@swc/register": "^0.1.10",
"@types/jest": "29.5.12",
"@types/node": "18.19.9",
"@types/supertest": "^2.0.12",
"@typeschema/arktype": "^0.13.2",
"@typeschema/core": "^0.13.2",
"@typeschema/io-ts": "^0.13.3",
"@typeschema/joi": "^0.13.3",
"@typeschema/json": "^0.13.3",
"@typeschema/main": "^0.13.10",
"@typeschema/ow": "^0.13.3",
"@typeschema/runtypes": "^0.13.2",
"@typeschema/superstruct": "^0.13.2",
"@typeschema/typebox": "^0.13.4",
"@typeschema/valibot": "^0.13.5",
"@typeschema/yup": "^0.13.3",
"@typeschema/zod": "^0.13.3",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
"ajv": "^8.12.0",
"@vitest/coverage-v8": "^1.0.4",
"@vitest/ui": "^1.3.1",
"ajv": "^8.17.1",
"arktype": "1.0.21-alpha",
"dotenv": "8.2.0",
"eslint": "8.57.0",
Expand All @@ -62,22 +80,25 @@
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jest-environment-node": "^29.4.1",
"joi": "^17.10.1",
"joi": "^17.13.3",
"nx": "19.6.1",
"ow": "^0.28.2",
"pactum": "^3.1.13",
"prettier": "^2.7.1",
"reflect-metadata": "^0.1.13",
"runtypes": "^6.7.0",
"rxjs": "^7.8.0",
"superstruct": "^1.0.3",
"superstruct": "^1.0.4",
"supertest": "^6.2.4",
"ts-jest": "29.1.0",
"ts-node": "10.9.1",
"tslib": "^2.4.0",
"typescript": "5.5.4",
"valibot": "^0.15.0",
"yup": "^1.2.0",
"zod": "^3.22.2"
"unplugin-swc": "^1.5.1",
"valibot": "^0.31.1",
"vite": "^5.4.2",
"vitest": "^2.0.5",
"yup": "^1.4.0",
"zod": "^3.23.8"
}
}
10 changes: 4 additions & 6 deletions packages/typeschema/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/typeschema/src",
"projectType": "library",
"tags": [],
"targets": {
"build": {
"executor": "@nx/js:tsc",
Expand All @@ -20,11 +21,9 @@
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/jest:jest",
"executor": "@nx/vite:test",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/typeschema/jest.config.ts"
}
"options": {}
},
"publish": {
"executor": "nx:run-commands",
Expand All @@ -38,6 +37,5 @@
}
]
}
},
"tags": []
}
}
5 changes: 3 additions & 2 deletions packages/typeschema/test/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import { INestApplication } from '@nestjs/common';
import { APP_PIPE } from '@nestjs/core';
import { Test } from '@nestjs/testing';
import { spec, request } from 'pactum';
import { afterAll, beforeAll, describe, it } from 'vitest';
import { AppController } from './app.controller';
import { ValidationPipe } from '../src';

const endpoints = [
{ endpoint: 'ajv' },
{ endpoint: 'arktype' },
{ endpoint: 'io-ts' },
// { endpoint: 'io-ts' },
{ endpoint: 'joi' },
{ endpoint: 'ow' },
// { endpoint: 'ow' },
{ endpoint: 'runtypes' },
{ endpoint: 'superstruct' },
{ endpoint: 'typebox' },
Expand Down
22 changes: 16 additions & 6 deletions packages/typeschema/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"],
"target": "es2021"
"types": [
"vitest/globals",
"vitest/importMeta",
"vite/client",
"node",
"vitest"
]
},
"include": [
"jest.config.ts",
"vite.config.ts",
"vitest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.d.ts",
"test/**/*.ts"
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
]
}
30 changes: 30 additions & 0 deletions packages/typeschema/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/// <reference types='vitest' />
import swc from 'unplugin-swc';
import { defineConfig } from 'vite';

import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';

export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/packages/typeschema',

plugins: [nxViteTsPaths(), swc.vite({ module: { type: 'es6' } })],

// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },

test: {
watch: false,
globals: true,
environment: 'node',
include: ['test/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],

reporters: ['default'],
coverage: {
reportsDirectory: '../../coverage/packages/typeschema',
provider: 'v8',
},
},
});
Loading