chore: upgrade jest (#2323)

* chore: upgrade jest

* fix: eslint

* chore: github action backend test

* fix: import

* chore: export

* fix: test
This commit is contained in:
ChengLei Shao 2023-07-26 17:53:51 +08:00 committed by GitHub
parent 54f240539c
commit 840254f517
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 660 additions and 1090 deletions

View File

@ -1,4 +1,9 @@
{
"env": {
"node": true,
"es6": true,
"browser": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",

View File

@ -38,9 +38,8 @@ jobs:
cache: 'yarn'
- run: yarn install
- name: Test with Sqlite
run: yarn nocobase install -f && yarn test
run: yarn nocobase install -f && node --max_old_space_size=4096 --no-compilation-cache ./node_modules/.bin/jest --maxWorkers=1 --workerIdleMemoryLimit=3000MB
env:
NODE_OPTIONS: '--max_old_space_size=4096'
DB_DIALECT: sqlite
DB_STORAGE: /tmp/db.sqlite
DB_UNDERSCORED: ${{ matrix.underscored }}
@ -80,9 +79,8 @@ jobs:
- run: yarn install
# - run: yarn build
- name: Test with postgres
run: yarn nocobase install -f && yarn test
run: yarn nocobase install -f && node --max_old_space_size=4096 --no-compilation-cache ./node_modules/.bin/jest --maxWorkers=1 --workerIdleMemoryLimit=3000MB
env:
NODE_OPTIONS: '--max_old_space_size=4096'
DB_DIALECT: postgres
DB_HOST: postgres
DB_PORT: 5432
@ -118,9 +116,8 @@ jobs:
- run: yarn install
# - run: yarn build
- name: Test with MySQL
run: yarn nocobase install -f && yarn test
run: yarn nocobase install -f && node --max_old_space_size=4096 --no-compilation-cache ./node_modules/.bin/jest --maxWorkers=1 --workerIdleMemoryLimit=3000MB
env:
NODE_OPTIONS: '--max_old_space_size=4096'
DB_DIALECT: mysql
DB_HOST: mysql
DB_PORT: 3306

View File

@ -1,4 +1,4 @@
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('./tsconfig.json');
const { defaults } = require('jest-config');
@ -6,26 +6,26 @@ module.exports = {
rootDir: process.cwd(),
collectCoverage: false,
verbose: true,
testEnvironment: 'jsdom',
preset: 'ts-jest',
testMatch: ['**/__tests__/**/*.test.[jt]s'],
setupFiles: ['./jest.setup.ts'],
setupFilesAfterEnv: [require.resolve('jest-dom/extend-expect'), './jest.setupAfterEnv.ts'],
setupFilesAfterEnv: ['./jest.setupAfterEnv.ts'],
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>/',
}),
},
globals: {
'ts-jest': {
transform: {
'^.+\\.{ts|tsx}?$': [
'ts-jest',
{
babelConfig: false,
tsconfig: './tsconfig.jest.json',
diagnostics: false,
},
],
},
modulePathIgnorePatterns: ['/esm/', '/es/', '/dist/', '/lib/', '/client/', '/sdk/', '\\.test\\.tsx$'],
// add .mjs .cjs for formula.js
moduleFileExtensions: [...defaults.moduleFileExtensions, 'mjs', 'cjs'],
coveragePathIgnorePatterns: [
'/node_modules/',
'/__tests__/',

View File

@ -7,7 +7,7 @@
"dependencies": {
"@nocobase/build": "0.11.1-alpha.3",
"@testing-library/react": "^12.1.5",
"@types/jest": "^26.0.0",
"@types/jest": "^29.0.0",
"@types/koa": "^2.13.4",
"@types/koa-bodyparser": "^4.3.4",
"@types/lodash": "^4.14.177",
@ -27,12 +27,9 @@
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.33.0",
"eslint-plugin-react-hooks": "^4.6.0",
"jest": "^26.0.0",
"jest-codemods": "^0.19.1",
"jest": "^29.0.0",
"jest-cli": "^29.0.0",
"jest-dom": "^3.1.2",
"jest-localstorage-mock": "^2.3.0",
"jest-styled-components": "6.3.3",
"jest-watch-lerna-packages": "^1.1.0",
"jsdom": "^16.0.0",
"lerna": "^4.0.0",
"prettier": "^3.0.0",
@ -42,7 +39,7 @@
"react-dom": "^18.0.0",
"rimraf": "^3.0.0",
"serve": "^13.0.2",
"ts-jest": "^26.0.0",
"ts-jest": "^29.0.0",
"ts-loader": "^7.0.4",
"ts-node": "9.1.1",
"ts-node-dev": "1.1.8",

View File

@ -1 +1,2 @@
export * from './server';
export { default } from './server';

View File

@ -1,7 +1,7 @@
import Database, { Collection as DBCollection, HasManyRepository } from '@nocobase/database';
import Application from '@nocobase/server';
import { createApp } from '.';
import CollectionManagerPlugin, { CollectionRepository } from '@nocobase/plugin-collection-manager';
import CollectionManagerPlugin, { CollectionRepository } from '../index';
describe('collections repository', () => {
let db: Database;

View File

@ -1,4 +1,7 @@
export * from './repositories';
export { default as fieldsCollection } from './collections/fields';
export { default as collectionsCollection } from './collections/collections';
export { default } from './server';

View File

@ -121,30 +121,15 @@ describe('fields', () => {
polygon: null,
});
expect(await findOne()).toMatchInlineSnapshot(`
Object {
"circle": Array [
114.058996,
22.549695,
4171,
expect(await findOne()).toMatchObject({
circle: [114.058996, 22.549695, 4171],
lineString: [
[114.047323, 22.534158],
[114.120966, 22.544146],
],
"lineString": Array [
Array [
114.047323,
22.534158,
],
Array [
114.120966,
22.544146,
],
],
"point": Array [
1,
2,
],
"polygon": null,
}
`);
point: [1, 2],
polygon: null,
});
});
it('empty', async () => {
@ -162,13 +147,11 @@ describe('fields', () => {
except: ['createdAt', 'updatedAt', 'id'],
});
expect(await findOne()).toMatchInlineSnapshot(`
Object {
"circle": null,
"lineString": null,
"point": null,
"polygon": null,
}
`);
expect(await findOne()).toMatchObject({
circle: null,
lineString: null,
point: null,
polygon: null,
});
});
});

View File

@ -1,4 +1,4 @@
import { UserPluginConfig } from '..';
import { UserPluginConfig } from '../server';
export const userPluginConfig: UserPluginConfig = {
name: 'users',

1648
yarn.lock

File diff suppressed because it is too large Load Diff