diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 233c43d..0a2265a 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -23,7 +23,9 @@ jobs: with: node-version: ${{ matrix.version }} - run: npm ci - - run: npm test + - run: npm run lint + - run: npm run test:unit + - run: npm run build test_all: if: ${{ always() }} diff --git a/package.json b/package.json index 79fe59a..0b51764 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,9 @@ "lint": "eslint src", "lint:fix": "eslint src --fix", "deps": "docker-compose up", - "test": "npm run lint && npm run test:api && npm run build", - "test:api": "jest tests --no-cache --no-watchman", + "test": "npm run lint && npm run test:unit && npm run test:api && npm run build", + "test:unit": "jest tests/unit --no-cache --no-watchman", + "test:api": "jest tests/api --no-cache --no-watchman", "generate-migration": "esbuild tests/utils/generate-migration.ts --bundle --platform=node --outdir=tmp --out-extension:.js=.cjs --format=cjs --packages=external && node tmp/generate-migration.cjs", "clean": "del-cli dist/**", "prebuild": "npm run clean", diff --git a/tests/__snapshots__/query.spec.ts.snap b/tests/api/__snapshots__/query.spec.ts.snap similarity index 100% rename from tests/__snapshots__/query.spec.ts.snap rename to tests/api/__snapshots__/query.spec.ts.snap diff --git a/tests/query.spec.ts b/tests/api/query.spec.ts similarity index 80% rename from tests/query.spec.ts rename to tests/api/query.spec.ts index 7738077..148ff7e 100644 --- a/tests/query.spec.ts +++ b/tests/api/query.spec.ts @@ -1,6 +1,6 @@ -import { gql } from '../src'; -import { ANOTHER_ID, SOME_ID } from './utils/database/seed'; -import { withServer } from './utils/server'; +import { gql } from '../../src'; +import { ANOTHER_ID, SOME_ID } from '../utils/database/seed'; +import { withServer } from '../utils/server'; describe('query', () => { it('can be executed', async () => { diff --git a/tests/__snapshots__/generate.spec.ts.snap b/tests/unit/__snapshots__/generate.spec.ts.snap similarity index 100% rename from tests/__snapshots__/generate.spec.ts.snap rename to tests/unit/__snapshots__/generate.spec.ts.snap diff --git a/tests/__snapshots__/resolve.spec.ts.snap b/tests/unit/__snapshots__/resolve.spec.ts.snap similarity index 100% rename from tests/__snapshots__/resolve.spec.ts.snap rename to tests/unit/__snapshots__/resolve.spec.ts.snap diff --git a/tests/generate.spec.ts b/tests/unit/generate.spec.ts similarity index 59% rename from tests/generate.spec.ts rename to tests/unit/generate.spec.ts index 15829cd..c3b0111 100644 --- a/tests/generate.spec.ts +++ b/tests/unit/generate.spec.ts @@ -1,5 +1,5 @@ -import { printSchemaFromModels } from '../src'; -import { rawModels } from './utils/models'; +import { printSchemaFromModels } from '../../src'; +import { rawModels } from '../utils/models'; describe('generate', () => { it('generates a schema', () => { diff --git a/tests/resolve.spec.ts b/tests/unit/resolve.spec.ts similarity index 91% rename from tests/resolve.spec.ts rename to tests/unit/resolve.spec.ts index 02e3934..711db4d 100644 --- a/tests/resolve.spec.ts +++ b/tests/unit/resolve.spec.ts @@ -2,11 +2,11 @@ import { makeExecutableSchema } from '@graphql-tools/schema'; import { execute, parse, Source } from 'graphql'; import knex from 'knex'; import { DateTime } from 'luxon'; -import { gql } from '../src/client/gql'; -import { Context } from '../src/context'; -import { generate } from '../src/generate'; -import { getResolvers } from '../src/resolvers'; -import { models, permissions, rawModels } from './utils/models'; +import { gql } from '../../src/client/gql'; +import { Context } from '../../src/context'; +import { generate } from '../../src/generate'; +import { getResolvers } from '../../src/resolvers'; +import { models, permissions, rawModels } from '../utils/models'; const test = async (operationName: string, query: string, variableValues: object, responses: unknown[]) => { const knexInstance = knex({ diff --git a/tsconfig.json b/tsconfig.json index da189e3..d8d4aee 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,9 @@ { - "include": ["./src/**/*.ts", "./src/**/*.tsx", "./tests/**/*.ts"], + "include": ["./src/**/*.ts", "./src/**/*.tsx"], "exclude": ["node_modules", "dist"], "compilerOptions": { "outDir": "./dist/esm", - "rootDir": "./", + "rootDir": "./src", "sourceMap": true, "declaration": true, "target": "esnext",