Skip to content

Commit

Permalink
Fixed failing tests due to an issue with babel 6: babel/babel#3083
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyaha committed Feb 5, 2017
1 parent 7229e79 commit b05428f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
5 changes: 4 additions & 1 deletion packages/common/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"transform-regenerator",
"transform-object-rest-spread",
"transform-async-to-generator",
"transform-flow-strip-types"
"transform-flow-strip-types",
["babel-plugin-transform-builtin-extend", {
"globals": ["Error", "Array"]
}]
]
}
1 change: 1 addition & 0 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"babel-loader": "^6.2.7",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-transform-async-to-generator": "^6.16.0",
"babel-plugin-transform-builtin-extend": "^1.1.0",
"babel-plugin-transform-flow-strip-types": "^6.21.0",
"babel-plugin-transform-object-rest-spread": "^6.16.0",
"babel-plugin-transform-regenerator": "^6.16.1",
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class AccountsError extends Error {
epochTime: number;

constructor(message: string, loginInfo?: PasswordLoginUserType, errorCode?: string | number) {
console.log(message);
super(message);
this.epochTime = Date.now();

Expand Down
37 changes: 16 additions & 21 deletions packages/common/src/errors.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,21 @@ describe('AccountsError class', () => {
}
});

it('should be able to serialize into a string', () => {
try {
throws();
} catch (e) {
expect(e.serialize()).toBe(
// eslint-disable-next-line prefer-template
'{"message":"Validation Error",' +
'"loginInfo":{"username":"user"},' +
'"errorCode":"ACCOUNTS:1",' +
'"epochTime":' + e.epochTime + '}',
);
}
});

// NB: For some reason it seems jest have different Error class
// it retain fields but our tests fail
// it('should be able to serialize into a string', () => {
// try {
// throws();
// } catch (e) {
// expect(e.serialize()).toBe(
// '{"message": "Validation Error", ' +
// '"loginInfo": { "username": "user" }, ' +
// '"errorCode": "ACCOUNTS:1" }'
// );
// }
// });
//
// it('should be easily distinguished from other errors', () => {
// try {
// throws();
// } catch (e) {
// expect(e instanceof AccountsError).toBeTruthy();
// }
// });
it('should be easily distinguished from other errors', () => {
expect(throws).toThrowError(AccountsError);
});
});

0 comments on commit b05428f

Please sign in to comment.