Skip to content

Commit

Permalink
Fix jest test in CI
Browse files Browse the repository at this point in the history
Jest runs out of memory when run in Docker, possibly because of a memory
leak in ts-jest.

The tests will now run after the build, on the built *.js files. As a
consequence, the jest tests will run faster because ts-jest will no
longer be invoked in ci.

Check the package.json test:ci script for more info.

jestjs/jest#7874
jestjs/jest#9081
  • Loading branch information
jeremija committed Jan 10, 2020
1 parent d3ae52c commit 1d8c23e
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ steps:
- npm install
- npm run lint
- npm run bootstrap
- ./node_modules/.bin/jest
- ./node_modules/.bin/lerna exec rondo -- build --esm
- npm run test:ci
- npm run esm
---
kind: signature
hmac: 75cb50df9833086e4b9705f592b78ee8c12479ab8b2041577c4660ecc8364295
hmac: 2a4dd894429afc6c3908a5d53cab57cac9a3918260a01e3f845db9aba53d6316

...
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"scripts": {
"clean": "lerna exec rimraf -- lib/ esm/ *.tsbuildinfo",
"clean": "lerna exec rimraf --stream -- lib/ esm/ *.tsbuildinfo",
"lint": "eslint --ext .ts,.tsx,.ts .",
"bootstrap": "ttsc --build packages/scripts && lerna exec rondo -- build"
"bootstrap": "ttsc --build packages/scripts && lerna exec rondo --stream -- build",
"esm": "lerna exec rondo --stream -- build --esm",
"test:ci": "jest --roots '<rootDir>/lib' --testRegex '\\.test\\.js$'",
"test": "jest"
},
"dependencies": {
"@rondo.dev/argparse": "file:packages/argparse",
Expand Down
4 changes: 2 additions & 2 deletions packages/captcha/src/audio.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import session from 'express-session'
import cookieParser from 'cookie-parser'
import request from 'supertest'
import { audio, speak } from './audio'
import { join } from 'path'
import { extname, join } from 'path'

describe('speak', () => {
it('writes speech data to stdin and returns rw streams', async () => {
Expand All @@ -23,7 +23,7 @@ describe('speak', () => {

const command = {
cmd: process.argv[0],
args: [join(__dirname, 'testProcess.ts')],
args: [join(__dirname, 'testProcess' + extname(__filename))],
contentType: 'text/plain',
}
const rw = await speak('mytest', [command])
Expand Down
4 changes: 2 additions & 2 deletions packages/captcha/src/run.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { run } from './run'
import { getError } from '@rondo.dev/test-utils'
import { join } from 'path'
import { extname, join } from 'path'

describe('run', () => {

Expand All @@ -22,7 +22,7 @@ describe('run', () => {
it('runs a process and returns stdin/stdout/contentType', async () => {
const result = await run({
cmd: process.argv[0],
args: [join(__dirname, 'testProcess.ts')],
args: [join(__dirname, 'testProcess' + extname(__filename))],
contentType: 'text/plain',
})
expect(result.contentType).toBe('text/plain')
Expand Down
6 changes: 3 additions & 3 deletions packages/config/src/ConfigReader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('ConfigReader', () => {

beforeAll(() => {
writeFileSync(
join(__dirname, 'test-files', 'package.json'),
join(__dirname, '..', 'test-files', 'package.json'),
'{}',
)
})
Expand All @@ -20,7 +20,7 @@ describe('ConfigReader', () => {

it('reads and merges configuration files from CWD', () => {
const config = new ConfigReader(
join(__dirname, 'test-files', 'dir'),
join(__dirname, '..', 'test-files', 'dir'),
'/tmp/path',
).read()
expect(config.value()).toEqual({
Expand Down Expand Up @@ -53,7 +53,7 @@ describe('ConfigReader', () => {
it('succeeds when config from env variable is read', () => {
process.env.CONFIG = '---\na: 2'
const config = new ConfigReader(
join(__dirname, 'test-files', 'dir'),
join(__dirname, '..', 'test-files', 'dir'),
'/tmp/path',
).read()
expect(config.value()).toEqual({
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions packages/jsonrpc/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
compiler: 'ttypescript',
},
},
testEnvironment: 'node',
roots: [
'<rootDir>/src',
],
Expand Down
4 changes: 0 additions & 4 deletions packages/jsonrpc/src/redux.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* @jest-environment node
*/

import { createStore } from '@rondo.dev/redux'
import bodyParser from 'body-parser'
import express from 'express'
Expand Down
4 changes: 0 additions & 4 deletions packages/jsonrpc/src/remote.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* @jest-environment node
*/

import bodyParser from 'body-parser'
import express from 'express'
import {AddressInfo} from 'net'
Expand Down
1 change: 1 addition & 0 deletions packages/server/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
roots: [
'<rootDir>/src',
],
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
Expand Down
2 changes: 0 additions & 2 deletions packages/server/src/test-utils/TestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ export class TestUtils<T extends Routes> {
})
.expect(200)

console.log('registered?')

const cookies = this.getCookies(response.header['set-cookie'])

return {
Expand Down

0 comments on commit 1d8c23e

Please sign in to comment.