Skip to content

Commit

Permalink
Merge pull request #32 from polem/update-jest-24
Browse files Browse the repository at this point in the history
Updade jest to 24, and update tests
  • Loading branch information
KariHe authored Nov 18, 2019
2 parents 2f21214 + 7db5372 commit f98b1e7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
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 @@ xdescribe('jest configuration', () => {
});

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

const tmp = testUtils.getTmpDirPath();
fs.ensureDirSync(tmp);
Expand Down Expand Up @@ -126,9 +126,9 @@ xdescribe('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 @@ -180,9 +180,9 @@ xdescribe('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);
});
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"
}
}

0 comments on commit f98b1e7

Please sign in to comment.