Skip to content

Commit

Permalink
introduced dockest & jest
Browse files Browse the repository at this point in the history
  • Loading branch information
erikengervall committed Aug 30, 2019
1 parent 6790a1b commit a79e0e8
Show file tree
Hide file tree
Showing 5 changed files with 1,721 additions and 35 deletions.
24 changes: 24 additions & 0 deletions dockest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const {
default: Dockest,
runners: { RedisRunner },
logLevel,
} = require('dockest')

const redis = new RedisRunner({
service: 'redis2000',
image: 'redis:5.0.3',
})

const dockest = new Dockest({
jest: {
lib: require('jest'),
verbose: true,
},
opts: {
logLevel: logLevel.DEBUG,
runInBand: true,
},
runners: [redis],
})

dockest.run()
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules/'],
roots: ['./routes'],
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"scripts": {
"prepublishOnly": "rm -rf ./build && yarn build",
"test": "node ./dockest.js",
"build": "NODE_ENV=production webpack",
"build:watch": "NODE_ENV=production webpack --watch",
"start": "node example.js",
Expand All @@ -41,9 +42,11 @@
"devDependencies": {
"babel-preset-react-app": "^7.0.2",
"css-loader": "^2.1.1",
"dockest": "^1.0.3",
"eslint": "^6.2.1",
"eslint-config-prettier": "^6.1.0",
"eslint-plugin-prettier": "^3.1.0",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"react-dev-utils": "^8.0.0",
"style-loader": "^0.23.1",
Expand Down
19 changes: 19 additions & 0 deletions routes/queues.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const queues = require('./queues')

jest.mock('./getDataForQeues', () => async () => '👋🏽 getDataForQeues')

describe('queues', () => {
const mockRequest = { app: { locals: { queues: jest.fn() } }, query: '' }
const mockResponse = { json: jest.fn() }

beforeEach(() => {
mockResponse.json.mockClear()
})

it('should work', async () => {
const result = await queues(mockRequest, mockResponse)

expect(result).toEqual(undefined)
expect(mockResponse.json).toHaveBeenCalledWith('👋🏽 getDataForQeues')
})
})
Loading

0 comments on commit a79e0e8

Please sign in to comment.