Skip to content

Commit

Permalink
Runs tests aginst the built module
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Apr 14, 2021
1 parent 3817687 commit 7c906ca
Show file tree
Hide file tree
Showing 28 changed files with 38 additions and 32 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default {
transform: {
'^.+\\.tsx?$': 'ts-jest',
preset: 'ts-jest',
moduleNameMapper: {
'^@mswjs/data(.*)': '<rootDir>/$1',
},
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion test/db/drop.test.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
2 changes: 1 addition & 1 deletion test/db/events.test.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion test/model/count.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/model/create.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/model/delete.test.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion test/model/deleteMany.test.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion test/model/findFirst.test.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion test/model/findMany.test.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion test/model/getAll.test.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
2 changes: 1 addition & 1 deletion test/model/toGraphQLHandlers.test.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion test/model/toRestHandlers.test.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion test/model/update.test.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion test/model/updateMany.test.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion test/performance/performance.test.ts
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion test/query/boolean.test.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
2 changes: 1 addition & 1 deletion test/query/date.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { random } from 'faker'
import { factory, primaryKey } from '../../src'
import { factory, primaryKey } from '@mswjs/data'

const setup = () => {
const db = factory({
Expand Down
2 changes: 1 addition & 1 deletion test/query/number.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { random } from 'faker'
import { factory, primaryKey } from '../../src'
import { factory, primaryKey } from '@mswjs/data'

const setup = () => {
const db = factory({
Expand Down
2 changes: 1 addition & 1 deletion test/query/pagination.test.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
2 changes: 1 addition & 1 deletion test/query/string.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { random } from 'faker'
import { factory, primaryKey } from '../../src'
import { factory, primaryKey } from '@mswjs/data'

const setup = () => {
const db = factory({
Expand Down
2 changes: 1 addition & 1 deletion test/relations/many-to-one.test.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
2 changes: 1 addition & 1 deletion test/relations/one-to-many.test.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
2 changes: 1 addition & 1 deletion test/relations/one-to-one.test.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
2 changes: 1 addition & 1 deletion test/relations/unique.test.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
2 changes: 1 addition & 1 deletion test/typings/typings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { factory, oneOf, primaryKey } from '../../src'
import { factory, oneOf, primaryKey } from '@mswjs/data'

const db = factory({
user: {
Expand Down
6 changes: 5 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
"declaration": true,
"moduleResolution": "node",
"downlevelIteration": true,
"esModuleInterop": true
"esModuleInterop": true,
"baseUrl": ".",
"paths": {
"@mswjs/data": ["."]
}
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
Expand Down

0 comments on commit 7c906ca

Please sign in to comment.