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:
parent
54f240539c
commit
840254f517
@ -1,4 +1,9 @@
|
|||||||
{
|
{
|
||||||
|
"env": {
|
||||||
|
"node": true,
|
||||||
|
"es6": true,
|
||||||
|
"browser": true
|
||||||
|
},
|
||||||
"extends": [
|
"extends": [
|
||||||
"eslint:recommended",
|
"eslint:recommended",
|
||||||
"plugin:@typescript-eslint/recommended",
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
9
.github/workflows/nocobase-test-backend.yml
vendored
9
.github/workflows/nocobase-test-backend.yml
vendored
@ -38,9 +38,8 @@ jobs:
|
|||||||
cache: 'yarn'
|
cache: 'yarn'
|
||||||
- run: yarn install
|
- run: yarn install
|
||||||
- name: Test with Sqlite
|
- 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:
|
env:
|
||||||
NODE_OPTIONS: '--max_old_space_size=4096'
|
|
||||||
DB_DIALECT: sqlite
|
DB_DIALECT: sqlite
|
||||||
DB_STORAGE: /tmp/db.sqlite
|
DB_STORAGE: /tmp/db.sqlite
|
||||||
DB_UNDERSCORED: ${{ matrix.underscored }}
|
DB_UNDERSCORED: ${{ matrix.underscored }}
|
||||||
@ -80,9 +79,8 @@ jobs:
|
|||||||
- run: yarn install
|
- run: yarn install
|
||||||
# - run: yarn build
|
# - run: yarn build
|
||||||
- name: Test with postgres
|
- 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:
|
env:
|
||||||
NODE_OPTIONS: '--max_old_space_size=4096'
|
|
||||||
DB_DIALECT: postgres
|
DB_DIALECT: postgres
|
||||||
DB_HOST: postgres
|
DB_HOST: postgres
|
||||||
DB_PORT: 5432
|
DB_PORT: 5432
|
||||||
@ -118,9 +116,8 @@ jobs:
|
|||||||
- run: yarn install
|
- run: yarn install
|
||||||
# - run: yarn build
|
# - run: yarn build
|
||||||
- name: Test with MySQL
|
- 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:
|
env:
|
||||||
NODE_OPTIONS: '--max_old_space_size=4096'
|
|
||||||
DB_DIALECT: mysql
|
DB_DIALECT: mysql
|
||||||
DB_HOST: mysql
|
DB_HOST: mysql
|
||||||
DB_PORT: 3306
|
DB_PORT: 3306
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const { pathsToModuleNameMapper } = require('ts-jest/utils');
|
const { pathsToModuleNameMapper } = require('ts-jest');
|
||||||
const { compilerOptions } = require('./tsconfig.json');
|
const { compilerOptions } = require('./tsconfig.json');
|
||||||
const { defaults } = require('jest-config');
|
const { defaults } = require('jest-config');
|
||||||
|
|
||||||
@ -6,26 +6,26 @@ module.exports = {
|
|||||||
rootDir: process.cwd(),
|
rootDir: process.cwd(),
|
||||||
collectCoverage: false,
|
collectCoverage: false,
|
||||||
verbose: true,
|
verbose: true,
|
||||||
testEnvironment: 'jsdom',
|
|
||||||
preset: 'ts-jest',
|
preset: 'ts-jest',
|
||||||
testMatch: ['**/__tests__/**/*.test.[jt]s'],
|
testMatch: ['**/__tests__/**/*.test.[jt]s'],
|
||||||
setupFiles: ['./jest.setup.ts'],
|
setupFiles: ['./jest.setup.ts'],
|
||||||
setupFilesAfterEnv: [require.resolve('jest-dom/extend-expect'), './jest.setupAfterEnv.ts'],
|
setupFilesAfterEnv: ['./jest.setupAfterEnv.ts'],
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
...pathsToModuleNameMapper(compilerOptions.paths, {
|
...pathsToModuleNameMapper(compilerOptions.paths, {
|
||||||
prefix: '<rootDir>/',
|
prefix: '<rootDir>/',
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
globals: {
|
transform: {
|
||||||
'ts-jest': {
|
'^.+\\.{ts|tsx}?$': [
|
||||||
babelConfig: false,
|
'ts-jest',
|
||||||
tsconfig: './tsconfig.jest.json',
|
{
|
||||||
diagnostics: false,
|
babelConfig: false,
|
||||||
},
|
tsconfig: './tsconfig.jest.json',
|
||||||
|
diagnostics: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
modulePathIgnorePatterns: ['/esm/', '/es/', '/dist/', '/lib/', '/client/', '/sdk/', '\\.test\\.tsx$'],
|
modulePathIgnorePatterns: ['/esm/', '/es/', '/dist/', '/lib/', '/client/', '/sdk/', '\\.test\\.tsx$'],
|
||||||
// add .mjs .cjs for formula.js
|
|
||||||
moduleFileExtensions: [...defaults.moduleFileExtensions, 'mjs', 'cjs'],
|
|
||||||
coveragePathIgnorePatterns: [
|
coveragePathIgnorePatterns: [
|
||||||
'/node_modules/',
|
'/node_modules/',
|
||||||
'/__tests__/',
|
'/__tests__/',
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nocobase/build": "0.11.1-alpha.3",
|
"@nocobase/build": "0.11.1-alpha.3",
|
||||||
"@testing-library/react": "^12.1.5",
|
"@testing-library/react": "^12.1.5",
|
||||||
"@types/jest": "^26.0.0",
|
"@types/jest": "^29.0.0",
|
||||||
"@types/koa": "^2.13.4",
|
"@types/koa": "^2.13.4",
|
||||||
"@types/koa-bodyparser": "^4.3.4",
|
"@types/koa-bodyparser": "^4.3.4",
|
||||||
"@types/lodash": "^4.14.177",
|
"@types/lodash": "^4.14.177",
|
||||||
@ -27,12 +27,9 @@
|
|||||||
"eslint-plugin-promise": "^6.1.1",
|
"eslint-plugin-promise": "^6.1.1",
|
||||||
"eslint-plugin-react": "^7.33.0",
|
"eslint-plugin-react": "^7.33.0",
|
||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^4.6.0",
|
||||||
"jest": "^26.0.0",
|
"jest": "^29.0.0",
|
||||||
"jest-codemods": "^0.19.1",
|
"jest-cli": "^29.0.0",
|
||||||
"jest-dom": "^3.1.2",
|
"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",
|
"jsdom": "^16.0.0",
|
||||||
"lerna": "^4.0.0",
|
"lerna": "^4.0.0",
|
||||||
"prettier": "^3.0.0",
|
"prettier": "^3.0.0",
|
||||||
@ -42,7 +39,7 @@
|
|||||||
"react-dom": "^18.0.0",
|
"react-dom": "^18.0.0",
|
||||||
"rimraf": "^3.0.0",
|
"rimraf": "^3.0.0",
|
||||||
"serve": "^13.0.2",
|
"serve": "^13.0.2",
|
||||||
"ts-jest": "^26.0.0",
|
"ts-jest": "^29.0.0",
|
||||||
"ts-loader": "^7.0.4",
|
"ts-loader": "^7.0.4",
|
||||||
"ts-node": "9.1.1",
|
"ts-node": "9.1.1",
|
||||||
"ts-node-dev": "1.1.8",
|
"ts-node-dev": "1.1.8",
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
export * from './server';
|
||||||
export { default } from './server';
|
export { default } from './server';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Database, { Collection as DBCollection, HasManyRepository } from '@nocobase/database';
|
import Database, { Collection as DBCollection, HasManyRepository } from '@nocobase/database';
|
||||||
import Application from '@nocobase/server';
|
import Application from '@nocobase/server';
|
||||||
import { createApp } from '.';
|
import { createApp } from '.';
|
||||||
import CollectionManagerPlugin, { CollectionRepository } from '@nocobase/plugin-collection-manager';
|
import CollectionManagerPlugin, { CollectionRepository } from '../index';
|
||||||
|
|
||||||
describe('collections repository', () => {
|
describe('collections repository', () => {
|
||||||
let db: Database;
|
let db: Database;
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
export * from './repositories';
|
export * from './repositories';
|
||||||
|
|
||||||
export { default as fieldsCollection } from './collections/fields';
|
export { default as fieldsCollection } from './collections/fields';
|
||||||
|
|
||||||
export { default as collectionsCollection } from './collections/collections';
|
export { default as collectionsCollection } from './collections/collections';
|
||||||
|
|
||||||
export { default } from './server';
|
export { default } from './server';
|
||||||
|
@ -121,30 +121,15 @@ describe('fields', () => {
|
|||||||
polygon: null,
|
polygon: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(await findOne()).toMatchInlineSnapshot(`
|
expect(await findOne()).toMatchObject({
|
||||||
Object {
|
circle: [114.058996, 22.549695, 4171],
|
||||||
"circle": Array [
|
lineString: [
|
||||||
114.058996,
|
[114.047323, 22.534158],
|
||||||
22.549695,
|
[114.120966, 22.544146],
|
||||||
4171,
|
],
|
||||||
],
|
point: [1, 2],
|
||||||
"lineString": Array [
|
polygon: null,
|
||||||
Array [
|
});
|
||||||
114.047323,
|
|
||||||
22.534158,
|
|
||||||
],
|
|
||||||
Array [
|
|
||||||
114.120966,
|
|
||||||
22.544146,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
"point": Array [
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
],
|
|
||||||
"polygon": null,
|
|
||||||
}
|
|
||||||
`);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('empty', async () => {
|
it('empty', async () => {
|
||||||
@ -162,13 +147,11 @@ describe('fields', () => {
|
|||||||
except: ['createdAt', 'updatedAt', 'id'],
|
except: ['createdAt', 'updatedAt', 'id'],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(await findOne()).toMatchInlineSnapshot(`
|
expect(await findOne()).toMatchObject({
|
||||||
Object {
|
circle: null,
|
||||||
"circle": null,
|
lineString: null,
|
||||||
"lineString": null,
|
point: null,
|
||||||
"point": null,
|
polygon: null,
|
||||||
"polygon": null,
|
});
|
||||||
}
|
|
||||||
`);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { UserPluginConfig } from '..';
|
import { UserPluginConfig } from '../server';
|
||||||
|
|
||||||
export const userPluginConfig: UserPluginConfig = {
|
export const userPluginConfig: UserPluginConfig = {
|
||||||
name: 'users',
|
name: 'users',
|
||||||
|
Loading…
Reference in New Issue
Block a user