Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updade jest to 24, and update tests #32

Merged
merged 2 commits into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions __tests__/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('jest configuration', () => {
});

beforeEach(() => {
jest.spyOn(jestConfig, 'readConfig');
jest.spyOn(jestConfig, 'readConfigs');

const tmp = testUtils.getTmpDirPath();
fs.ensureDirSync(tmp);
Expand Down Expand Up @@ -124,9 +124,9 @@ describe('jest configuration', () => {
})
.catch(e => expect(e).toBeUndefined())
.then(() => {
expect(jestConfig.readConfig).toHaveBeenCalled();
expect(jestConfig.readConfigs).toHaveBeenCalled();

const [[globalConfig]] = jestConfig.readConfig.mock.calls;
const [[globalConfig]] = jestConfig.readConfigs.mock.calls;

expect(globalConfig).toBeDefined();
expect(globalConfig).toMatchObject({
Expand Down Expand Up @@ -176,9 +176,9 @@ describe('jest configuration', () => {
})
.catch(err => expect(err).toBeUndefined())
.then(() => {
expect(jestConfig.readConfig).toHaveBeenCalled();
expect(jestConfig.readConfigs).toHaveBeenCalled();

const [[globalConfig]] = jestConfig.readConfig.mock.calls;
const [[globalConfig]] = jestConfig.readConfigs.mock.calls;

expect(globalConfig).toBeDefined();
expect(globalConfig).toMatchObject({
Expand Down
6 changes: 4 additions & 2 deletions __tests__/integration-options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Serverless = require('serverless');
const execSync = require('child_process').execSync;
const path = require('path');
const fs = require('fs-extra');
const stripAnsi = require('strip-ansi');
const {
getTmpDirPath,
replaceTextInFile,
Expand Down Expand Up @@ -76,8 +77,9 @@ describe('integration', () => {

return spawnPromise(serverlessExec, 'invoke test --stage prod')
.then(({ stderr }) => {
expect(stderr).toContain('PASS');
return expect(stderr).toContain('Test Suites: 2 passed, 2 total');
const rawStderr = stripAnsi(stderr);
expect(rawStderr).toContain('PASS');
return expect(rawStderr).toContain('Test Suites: 2 passed, 2 total');
});
}, 120000);
});
80 changes: 0 additions & 80 deletions __tests__/integration6.10.test.js

This file was deleted.

6 changes: 4 additions & 2 deletions __tests__/integration8.10.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Serverless = require('serverless');
const execSync = require('child_process').execSync;
const path = require('path');
const fs = require('fs-extra');
const stripAnsi = require('strip-ansi');
const { getTmpDirPath, replaceTextInFile, spawnPromise } = require('./test-utils');

const serverless = new Serverless();
Expand Down Expand Up @@ -71,8 +72,9 @@ describe('integration', () => {
"require('../.serverless_plugins/serverless-jest-plugin/index.js')",
);
return spawnPromise(serverlessExec, 'invoke test --stage prod').then(({ stderr }) => {
expect(stderr).toContain('PASS');
return expect(stderr).toContain('Test Suites: 2 passed, 2 total');
const rawStderr = stripAnsi(stderr);
expect(rawStderr).toContain('PASS');
return expect(rawStderr).toContain('Test Suites: 2 passed, 2 total');
});
},
35000,
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"bluebird": "^3.5.2",
"ejs": "^2.6.1",
"fs-extra": "^3.0.0",
"jest": "^23.6.0",
"jest": "^24.5.0",
"lambda-wrapper": "^0.3.0",
"yaml-edit": "^0.1.3"
},
Expand All @@ -32,6 +32,7 @@
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.9.0",
"serverless": "^1.32.0"
"serverless": "^1.32.0",
"strip-ansi": "chalk/strip-ansi"
}
}