diff --git a/packages/nocodb/package.json b/packages/nocodb/package.json index 97493a8f58..87349ab147 100644 --- a/packages/nocodb/package.json +++ b/packages/nocodb/package.json @@ -21,11 +21,10 @@ "local:test:graphql": "cross-env DATABASE_URL=mysql://root:password@localhost:3306/sakila TS_NODE_PROJECT=tsconfig.json mocha -r ts-node/register src/__tests__/graphql.test.ts --recursive --timeout 10000 --exit", "test:graphql": "cross-env TS_NODE_PROJECT=tsconfig.json mocha -r ts-node/register src/__tests__/graphql.test.ts --recursive --timeout 10000 --exit", "test:grpc": "cross-env TS_NODE_PROJECT=tsconfig.json mocha -r ts-node/register src/__tests__/grpc.test.ts --recursive --timeout 10000 --exit", - "local:test:rest": "cross-env TS_NODE_PROJECT=./tests/unit/tsconfig.json mocha -r ts-node/register tests/unit/rest/index.test.ts --recursive --timeout 300000 --exit --delay", - "test:rest": "cross-env TS_NODE_PROJECT=./tests/unit/tsconfig.json mocha -r ts-node/register tests/unit/rest/index.test.ts --recursive --timeout 300000 --exit --delay", + "local:test:unit": "cross-env TS_NODE_PROJECT=./tests/unit/tsconfig.json mocha -r ts-node/register tests/unit/index.test.ts --recursive --timeout 300000 --exit --delay", + "test:unit": "cross-env TS_NODE_PROJECT=./tests/unit/tsconfig.json mocha -r ts-node/register tests/unit/index.test.ts --recursive --timeout 300000 --exit --delay", "test1": "run-s build test:*", "test:lint": "tslint --project . && prettier \"src/**/*.ts\" --list-different", - "test:unit": "nyc --silent ava", "watch": "run-s clean build:main && run-p \"build:main -- -w\" \"test:unit -- --watch\"", "cov": "run-s build test:unit cov:html && open-cli coverage/index.html", "cov:html": "nyc report --reporter=html", diff --git a/packages/nocodb/tests/unit/index.test.ts b/packages/nocodb/tests/unit/index.test.ts new file mode 100644 index 0000000000..5147d7757d --- /dev/null +++ b/packages/nocodb/tests/unit/index.test.ts @@ -0,0 +1,35 @@ +import 'mocha'; + +import knex from 'knex'; +import { dbName } from './dbConfig'; +import restTests from './rest/index.test'; + +process.env.NODE_ENV = 'test'; +process.env.TEST = 'test'; +process.env.NC_DISABLE_CACHE = 'true'; + +const setupTestMetaDb = async () => { + const knexClient = knex({ + client: 'mysql2', + connection: { + host: 'localhost', + port: 3306, + user: 'root', + password: 'password', + }, + }); + + try { + await knexClient.raw(`DROP DATABASE ${dbName}`); + } catch (e) {} + + await knexClient.raw(`CREATE DATABASE ${dbName}`); +} + +(async function() { + await setupTestMetaDb(); + + restTests(); + + run(); +})(); \ No newline at end of file diff --git a/packages/nocodb/tests/unit/model/baseModelSql.test.ts b/packages/nocodb/tests/unit/model/tests/baseModelSql.test.ts similarity index 100% rename from packages/nocodb/tests/unit/model/baseModelSql.test.ts rename to packages/nocodb/tests/unit/model/tests/baseModelSql.test.ts diff --git a/packages/nocodb/tests/unit/rest/index.test.ts b/packages/nocodb/tests/unit/rest/index.test.ts index e38186b6de..2944f6395a 100644 --- a/packages/nocodb/tests/unit/rest/index.test.ts +++ b/packages/nocodb/tests/unit/rest/index.test.ts @@ -4,39 +4,15 @@ import projectTests from './tests/project.test'; import tableTests from './tests/table.test'; import tableRowTests from './tests/tableRow.test'; import viewRowTests from './tests/viewRow.test'; -import knex from 'knex'; -import { dbName } from '../dbConfig'; - -process.env.NODE_ENV = 'test'; -process.env.TEST = 'test'; -process.env.NC_DISABLE_CACHE = 'true'; - -const setupTestMetaDb = async () => { - const knexClient = knex({ - client: 'mysql2', - connection: { - host: 'localhost', - port: 3306, - user: 'root', - password: 'password', - }, - }); - - try { - await knexClient.raw(`DROP DATABASE ${dbName}`); - } catch (e) {} - - await knexClient.raw(`CREATE DATABASE ${dbName}`); -} - -(async function() { - await setupTestMetaDb(); +function restTests() { authTests(); projectTests(); tableTests(); tableRowTests(); viewRowTests(); +} - run(); -})(); \ No newline at end of file +export default function () { + describe('Rest', restTests); +} \ No newline at end of file