Skip to content

Commit

Permalink
test: skip the performance tests (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito authored Oct 12, 2021
1 parent 012d2e2 commit 9f88f0d
Showing 1 changed file with 97 additions and 95 deletions.
192 changes: 97 additions & 95 deletions test/performance/performance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,124 +2,126 @@ import { datatype, random, name } from 'faker'
import { factory, primaryKey } from '@mswjs/data'
import { measurePerformance, repeat } from '../testUtils'

test('creates a 1000 records in under 100ms', async () => {
const db = factory({
user: {
id: primaryKey(datatype.uuid),
firstName: name.firstName,
lastName: name.lastName,
age: datatype.number,
role: random.word,
},
})

const createPerformance = await measurePerformance('create', () => {
repeat(db.user.create, 1000)
})
describe.skip('Performance testing', () => {
test('creates a 1000 records in under 100ms', async () => {
const db = factory({
user: {
id: primaryKey(datatype.uuid),
firstName: name.firstName,
lastName: name.lastName,
age: datatype.number,
role: random.word,
},
})

expect(createPerformance.duration).toBeLessThanOrEqual(350)
})
const createPerformance = await measurePerformance('create', () => {
repeat(db.user.create, 1000)
})

test('queries through a 1000 records in under 100ms', async () => {
const db = factory({
user: {
id: primaryKey(datatype.uuid),
firstName: name.firstName,
lastName: name.lastName,
age: datatype.number,
role: random.word,
},
expect(createPerformance.duration).toBeLessThanOrEqual(350)
})
repeat(db.user.create, 1000)

const findManyPerformance = await measurePerformance('findMany', () => {
db.user.findMany({
where: {
age: {
gte: 18,
},
test('queries through a 1000 records in under 100ms', async () => {
const db = factory({
user: {
id: primaryKey(datatype.uuid),
firstName: name.firstName,
lastName: name.lastName,
age: datatype.number,
role: random.word,
},
})
})
repeat(db.user.create, 1000)

expect(findManyPerformance.duration).toBeLessThanOrEqual(350)
})
const findManyPerformance = await measurePerformance('findMany', () => {
db.user.findMany({
where: {
age: {
gte: 18,
},
},
})
})

test('updates a single record under 100ms', async () => {
const db = factory({
user: {
id: primaryKey(datatype.uuid),
firstName: name.firstName,
lastName: name.lastName,
age: datatype.number,
role: random.word,
},
expect(findManyPerformance.duration).toBeLessThanOrEqual(350)
})
repeat(db.user.create, 1000)

const updatePerformance = await measurePerformance('update', () => {
db.user.update({
where: {
age: {
lte: 20,
},
},
data: {
age: 21,
test('updates a single record under 100ms', async () => {
const db = factory({
user: {
id: primaryKey(datatype.uuid),
firstName: name.firstName,
lastName: name.lastName,
age: datatype.number,
role: random.word,
},
})
})
repeat(db.user.create, 1000)

expect(updatePerformance.duration).toBeLessThanOrEqual(350)
})
const updatePerformance = await measurePerformance('update', () => {
db.user.update({
where: {
age: {
lte: 20,
},
},
data: {
age: 21,
},
})
})

test('deletes a single record in under 100ms', async () => {
const db = factory({
user: {
id: primaryKey(datatype.uuid),
firstName: name.firstName,
lastName: name.lastName,
age: datatype.number,
role: random.word,
},
expect(updatePerformance.duration).toBeLessThanOrEqual(350)
})
repeat(db.user.create, 999)
db.user.create({ id: 'abc-123' })

const deletePerformance = await measurePerformance('delete', () => {
db.user.delete({
where: {
id: {
equals: 'abc-123',
},
test('deletes a single record in under 100ms', async () => {
const db = factory({
user: {
id: primaryKey(datatype.uuid),
firstName: name.firstName,
lastName: name.lastName,
age: datatype.number,
role: random.word,
},
})
})
repeat(db.user.create, 999)
db.user.create({ id: 'abc-123' })

expect(deletePerformance.duration).toBeLessThanOrEqual(350)
})
const deletePerformance = await measurePerformance('delete', () => {
db.user.delete({
where: {
id: {
equals: 'abc-123',
},
},
})
})

test('deletes multiple records in under 100ms', async () => {
const db = factory({
user: {
id: primaryKey(datatype.uuid),
firstName: name.firstName,
lastName: name.lastName,
age: datatype.number,
role: random.word,
},
expect(deletePerformance.duration).toBeLessThanOrEqual(350)
})
repeat(db.user.create, 1000)

const deleteManyPerformance = await measurePerformance('deleteMany', () => {
db.user.deleteMany({
where: {
age: {
lte: 18,
},
test('deletes multiple records in under 100ms', async () => {
const db = factory({
user: {
id: primaryKey(datatype.uuid),
firstName: name.firstName,
lastName: name.lastName,
age: datatype.number,
role: random.word,
},
})
})
repeat(db.user.create, 1000)

expect(deleteManyPerformance.duration).toBeLessThanOrEqual(350)
const deleteManyPerformance = await measurePerformance('deleteMany', () => {
db.user.deleteMany({
where: {
age: {
lte: 18,
},
},
})
})

expect(deleteManyPerformance.duration).toBeLessThanOrEqual(350)
})
})

0 comments on commit 9f88f0d

Please sign in to comment.