Skip to content

Commit e98f296

Browse files
committed
feat: add automatic tests
1 parent 5c431ae commit e98f296

File tree

4 files changed

+2101
-36
lines changed

4 files changed

+2101
-36
lines changed

jest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
roots: ['<rootDir>/src'],
3+
testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'],
4+
transform: {
5+
'^.+\\.(ts|tsx)$': 'ts-jest',
6+
},
7+
}

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,23 @@
3030
"dev:test-app": "cd test-app && yarn dev",
3131
"dev": "yarn watch & yarn dev:test-app",
3232
"build": "rimraf ./dist && tsc",
33-
"stable": "dripip stable"
33+
"stable": "dripip stable",
34+
"test": "jest",
35+
"test:watch": "jest --watch"
3436
},
3537
"dependencies": {},
3638
"devDependencies": {
3739
"@prisma-labs/prettier-config": "0.1.0",
40+
"@types/jest": "^26.0.15",
3841
"@types/webpack": "4.41.22",
3942
"dripip": "0.10.0",
4043
"eslint": "7.10.0",
4144
"eslint-config-prettier": "6.12.0",
45+
"jest": "^26.6.0",
4246
"prettier": "2.1.2",
4347
"prettier-eslint": "11.0.0",
4448
"rimraf": "^3.0.2",
49+
"ts-jest": "^26.4.1",
4550
"typescript": "4.0.3",
4651
"webpack": "4.44.2"
4752
},

src/__tests__/index.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import withPrismaPlugin from '../index'
2+
3+
describe('withPrismaPlugin', () => {
4+
it('should keep nextConfig object properties in other phases', () => {
5+
const nextConfig = { foo: 'bar' }
6+
7+
const newConfig = withPrismaPlugin(nextConfig)('NO_PHASE', {})
8+
expect(newConfig).toEqual(nextConfig)
9+
})
10+
11+
it('should call nextConfig function in other phases', () => {
12+
const nextConfig = () => ({ foo: 'bar' })
13+
14+
const newConfig = withPrismaPlugin(nextConfig)('NO_PHASE', {})
15+
expect(newConfig).toEqual(nextConfig())
16+
})
17+
18+
it('should add webpack property', () => {
19+
const nextConfig = { foo: 'bar' }
20+
21+
const newConfig = withPrismaPlugin(nextConfig)('phase-development-server', {})
22+
expect(newConfig).toHaveProperty('webpack')
23+
})
24+
})

0 commit comments

Comments
 (0)