Fix jest test in CI
Some checks failed
continuous-integration/drone/push Build is failing

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.

https://github.com/facebook/jest/issues/7874
https://github.com/facebook/jest/issues/9081
This commit is contained in:
Jerko Steiner 2020-01-10 10:30:16 +01:00
parent d3ae52c79a
commit a5eb3d8bea
13 changed files with 17 additions and 22 deletions

View File

@ -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 jest
- npm run esm
---
kind: signature
hmac: 75cb50df9833086e4b9705f592b78ee8c12479ab8b2041577c4660ecc8364295
hmac: ccaae75bbb4cb95e9e82761ffaf6fe1293e5a35b4b7dca077f38837e44e567fa
...

View File

@ -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",

View File

@ -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 () => {
@ -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])

View File

@ -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', () => {
@ -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')

View File

@ -6,7 +6,7 @@ describe('ConfigReader', () => {
beforeAll(() => {
writeFileSync(
join(__dirname, 'test-files', 'package.json'),
join(__dirname, '..', 'test-files', 'package.json'),
'{}',
)
})
@ -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({
@ -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({

View File

@ -4,6 +4,7 @@ module.exports = {
compiler: 'ttypescript',
},
},
testEnvironment: 'node',
roots: [
'<rootDir>/src',
],

View File

@ -1,7 +1,3 @@
/**
* @jest-environment node
*/
import { createStore } from '@rondo.dev/redux'
import bodyParser from 'body-parser'
import express from 'express'

View File

@ -1,7 +1,3 @@
/**
* @jest-environment node
*/
import bodyParser from 'body-parser'
import express from 'express'
import {AddressInfo} from 'net'

View File

@ -2,6 +2,7 @@ module.exports = {
roots: [
'<rootDir>/src',
],
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},

View File

@ -138,8 +138,6 @@ export class TestUtils<T extends Routes> {
})
.expect(200)
console.log('registered?')
const cookies = this.getCookies(response.header['set-cookie'])
return {