diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 41b18143..8269c918 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,13 +24,13 @@ jobs: - name: Install dependencies run: yarn install --frozen-lockfile + # Build + - name: Build + run: yarn build + # Runs a single command using the runners shell - name: Tests run: yarn test - name: Tests (typings) run: yarn test:ts - - # Build - - name: Build - run: yarn build diff --git a/jest.config.ts b/jest.config.ts index 7d2e3424..65b735cf 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -1,5 +1,6 @@ export default { - transform: { - '^.+\\.tsx?$': 'ts-jest', + preset: 'ts-jest', + moduleNameMapper: { + '^@mswjs/data(.*)': '/$1', }, } diff --git a/package.json b/package.json index b4974ceb..d1ad24d0 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,13 @@ "author": "Artem Zakharchenko", "license": "MIT", "scripts": { + "start": "tsc -w", "format": "prettier src/**/*.ts --write", "test": "jest", "test:ts": "tsc -p test/typings/tsconfig.json", "clean": "rimraf ./lib", "build": "yarn clean && tsc", - "prepublishOnly": "yarn test && yarn test:ts && yarn build" + "prepublishOnly": "yarn build && yarn test:ts && yarn test" }, "files": [ "lib", diff --git a/test/db/drop.test.ts b/test/db/drop.test.ts index cd882b43..f7c45943 100644 --- a/test/db/drop.test.ts +++ b/test/db/drop.test.ts @@ -1,4 +1,4 @@ -import { drop, factory, identity, primaryKey } from '../../src' +import { drop, factory, identity, primaryKey } from '@mswjs/data' test('drops all records in the database', () => { const db = factory({ diff --git a/test/db/events.test.ts b/test/db/events.test.ts index ff246837..b193b5df 100644 --- a/test/db/events.test.ts +++ b/test/db/events.test.ts @@ -1,4 +1,4 @@ -import { primaryKey } from '../../src' +import { primaryKey } from '@mswjs/data' import { Database } from '../../src/db/Database' import { createModel } from '../../src/model/createModel' diff --git a/test/model/count.test.ts b/test/model/count.test.ts index fc287b64..4487e31e 100644 --- a/test/model/count.test.ts +++ b/test/model/count.test.ts @@ -1,5 +1,5 @@ import { random } from 'faker' -import { factory, primaryKey } from '../../src' +import { factory, primaryKey } from '@mswjs/data' import { repeat } from '../testUtils' test('counts the amount of records for the model', () => { diff --git a/test/model/create.test.ts b/test/model/create.test.ts index c912e177..6852a713 100644 --- a/test/model/create.test.ts +++ b/test/model/create.test.ts @@ -1,5 +1,5 @@ import { random } from 'faker' -import { factory, primaryKey } from '../../src' +import { factory, primaryKey } from '@mswjs/data' import { identity } from '../../src/utils/identity' test('creates a new entity', () => { diff --git a/test/model/delete.test.ts b/test/model/delete.test.ts index 298888d7..79527e92 100644 --- a/test/model/delete.test.ts +++ b/test/model/delete.test.ts @@ -1,5 +1,5 @@ import { random, name } from 'faker' -import { factory, primaryKey } from '../../src' +import { factory, primaryKey } from '@mswjs/data' import { OperationErrorType } from '../../src/errors/OperationError' import { getThrownError } from '../testUtils' diff --git a/test/model/deleteMany.test.ts b/test/model/deleteMany.test.ts index 13b507e8..3f56d23e 100644 --- a/test/model/deleteMany.test.ts +++ b/test/model/deleteMany.test.ts @@ -1,5 +1,5 @@ import { random, name } from 'faker' -import { factory, primaryKey } from '../../src' +import { factory, primaryKey } from '@mswjs/data' import { OperationErrorType } from '../../src/errors/OperationError' import { getThrownError } from '../testUtils' diff --git a/test/model/findFirst.test.ts b/test/model/findFirst.test.ts index 1aed9142..dd200538 100644 --- a/test/model/findFirst.test.ts +++ b/test/model/findFirst.test.ts @@ -1,5 +1,5 @@ import { random } from 'faker' -import { factory, primaryKey } from '../../src' +import { factory, primaryKey } from '@mswjs/data' import { OperationErrorType } from '../../src/errors/OperationError' import { identity } from '../../src/utils/identity' import { getThrownError } from '../testUtils' diff --git a/test/model/findMany.test.ts b/test/model/findMany.test.ts index 6872250d..8baedf25 100644 --- a/test/model/findMany.test.ts +++ b/test/model/findMany.test.ts @@ -1,5 +1,5 @@ import { random } from 'faker' -import { factory, primaryKey } from '../../src' +import { factory, primaryKey } from '@mswjs/data' import { OperationErrorType } from '../../src/errors/OperationError' import { getThrownError } from '../testUtils' diff --git a/test/model/getAll.test.ts b/test/model/getAll.test.ts index e2c3f8ed..89ba7792 100644 --- a/test/model/getAll.test.ts +++ b/test/model/getAll.test.ts @@ -1,5 +1,5 @@ import { random } from 'faker' -import { factory, primaryKey } from '../../src' +import { factory, primaryKey } from '@mswjs/data' test('returns all entities', () => { const db = factory({ diff --git a/test/model/toGraphQLHandlers.test.ts b/test/model/toGraphQLHandlers.test.ts index 3ffe511b..976fa712 100644 --- a/test/model/toGraphQLHandlers.test.ts +++ b/test/model/toGraphQLHandlers.test.ts @@ -1,7 +1,7 @@ import fetch from 'node-fetch' import { random } from 'faker' import { setupServer } from 'msw/node' -import { factory, primaryKey, drop } from '../../src' +import { factory, primaryKey, drop } from '@mswjs/data' const db = factory({ user: { diff --git a/test/model/toRestHandlers.test.ts b/test/model/toRestHandlers.test.ts index f58539ab..4ce1ffe8 100644 --- a/test/model/toRestHandlers.test.ts +++ b/test/model/toRestHandlers.test.ts @@ -1,7 +1,7 @@ import fetch from 'node-fetch' import { name, random } from 'faker' import { setupServer } from 'msw/node' -import { factory, drop, primaryKey } from '../../src' +import { factory, drop, primaryKey } from '@mswjs/data' const db = factory({ user: { diff --git a/test/model/update.test.ts b/test/model/update.test.ts index 7da93f9a..bdd8b9be 100644 --- a/test/model/update.test.ts +++ b/test/model/update.test.ts @@ -1,5 +1,5 @@ import { random, name } from 'faker' -import { factory, primaryKey } from '../../src' +import { factory, primaryKey } from '@mswjs/data' import { OperationErrorType } from '../../src/errors/OperationError' import { getThrownError } from '../testUtils' diff --git a/test/model/updateMany.test.ts b/test/model/updateMany.test.ts index f2d56a3b..5139787d 100644 --- a/test/model/updateMany.test.ts +++ b/test/model/updateMany.test.ts @@ -1,5 +1,5 @@ import { random, name } from 'faker' -import { factory, primaryKey } from '../../src' +import { factory, primaryKey } from '@mswjs/data' import { OperationErrorType } from '../../src/errors/OperationError' import { getThrownError } from '../testUtils' diff --git a/test/performance/performance.test.ts b/test/performance/performance.test.ts index 52615e8b..e3e94d71 100644 --- a/test/performance/performance.test.ts +++ b/test/performance/performance.test.ts @@ -1,5 +1,5 @@ import { random, name } from 'faker' -import { factory, primaryKey } from '../../src' +import { factory, primaryKey } from '@mswjs/data' import { measurePerformance, repeat } from '../testUtils' test('creates a 1000 records in under 100ms', async () => { diff --git a/test/query/boolean.test.ts b/test/query/boolean.test.ts index 8ef2e37b..5cd3dc60 100644 --- a/test/query/boolean.test.ts +++ b/test/query/boolean.test.ts @@ -1,5 +1,5 @@ import { random } from 'faker' -import { factory, primaryKey } from '../../src' +import { factory, primaryKey } from '@mswjs/data' test('queries entities based on a boolean value', () => { const db = factory({ diff --git a/test/query/date.test.ts b/test/query/date.test.ts index d8229341..4f43f3d4 100644 --- a/test/query/date.test.ts +++ b/test/query/date.test.ts @@ -1,5 +1,5 @@ import { random } from 'faker' -import { factory, primaryKey } from '../../src' +import { factory, primaryKey } from '@mswjs/data' const setup = () => { const db = factory({ diff --git a/test/query/number.test.ts b/test/query/number.test.ts index e15c71d4..4f087aea 100644 --- a/test/query/number.test.ts +++ b/test/query/number.test.ts @@ -1,5 +1,5 @@ import { random } from 'faker' -import { factory, primaryKey } from '../../src' +import { factory, primaryKey } from '@mswjs/data' const setup = () => { const db = factory({ diff --git a/test/query/pagination.test.ts b/test/query/pagination.test.ts index 7e07d1cd..d2412fa0 100644 --- a/test/query/pagination.test.ts +++ b/test/query/pagination.test.ts @@ -1,5 +1,5 @@ import { random } from 'faker' -import { factory, primaryKey } from '../../src' +import { factory, primaryKey } from '@mswjs/data' test('supports offset-based pagination', () => { const db = factory({ diff --git a/test/query/string.test.ts b/test/query/string.test.ts index d90c14b3..3f3f5d46 100644 --- a/test/query/string.test.ts +++ b/test/query/string.test.ts @@ -1,5 +1,5 @@ import { random } from 'faker' -import { factory, primaryKey } from '../../src' +import { factory, primaryKey } from '@mswjs/data' const setup = () => { const db = factory({ diff --git a/test/relations/many-to-one.test.ts b/test/relations/many-to-one.test.ts index ee9f989b..d4e8b3b2 100644 --- a/test/relations/many-to-one.test.ts +++ b/test/relations/many-to-one.test.ts @@ -1,5 +1,5 @@ import { random, name } from 'faker' -import { factory, oneOf, primaryKey } from '../../src' +import { factory, oneOf, primaryKey } from '@mswjs/data' test('supports querying against a many-to-one relation', () => { const db = factory({ diff --git a/test/relations/one-to-many.test.ts b/test/relations/one-to-many.test.ts index b73f64ab..714700ba 100644 --- a/test/relations/one-to-many.test.ts +++ b/test/relations/one-to-many.test.ts @@ -1,5 +1,5 @@ import { random } from 'faker' -import { factory, primaryKey, manyOf } from '../../src' +import { factory, primaryKey, manyOf } from '@mswjs/data' test('supports one-to-many relation', () => { const db = factory({ diff --git a/test/relations/one-to-one.test.ts b/test/relations/one-to-one.test.ts index ae6165a3..527bd218 100644 --- a/test/relations/one-to-one.test.ts +++ b/test/relations/one-to-one.test.ts @@ -1,5 +1,5 @@ import { random } from 'faker' -import { factory, primaryKey, oneOf } from '../../src' +import { factory, primaryKey, oneOf } from '@mswjs/data' test('supports one-to-one relation', () => { const db = factory({ diff --git a/test/relations/unique.test.ts b/test/relations/unique.test.ts index b8148275..07c77504 100644 --- a/test/relations/unique.test.ts +++ b/test/relations/unique.test.ts @@ -1,4 +1,4 @@ -import { factory, manyOf, oneOf, primaryKey } from '../../src' +import { factory, manyOf, oneOf, primaryKey } from '@mswjs/data' test('throws an error when using an already associated "oneOf" unique relation', () => { const db = factory({ diff --git a/test/typings/typings.ts b/test/typings/typings.ts index 84976bb2..3b62c778 100644 --- a/test/typings/typings.ts +++ b/test/typings/typings.ts @@ -1,4 +1,4 @@ -import { factory, oneOf, primaryKey } from '../../src' +import { factory, oneOf, primaryKey } from '@mswjs/data' const db = factory({ user: { diff --git a/tsconfig.json b/tsconfig.json index 62507e13..b88157f7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,11 @@ "declaration": true, "moduleResolution": "node", "downlevelIteration": true, - "esModuleInterop": true + "esModuleInterop": true, + "baseUrl": ".", + "paths": { + "@mswjs/data": ["."] + } }, "include": ["src/**/*.ts"], "exclude": ["node_modules"]