Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

Commit 3886540

Browse files
greenkeeper[bot]spudly
authored andcommitted
feat(displayName): updated dependencies, switched to jest & prettier
* chore(package): update dependencies https://greenkeeper.io/ * feat(no-mangle): upgrade deps, switch to jest and prettier
1 parent 7d7533c commit 3886540

File tree

6 files changed

+4755
-82
lines changed

6 files changed

+4755
-82
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ node_js:
44
- '4'
55
- '5'
66
- '6'
7+
- '7'
78
after_success:
89
- 'curl -Lo travis_after_all.py https://git.io/travis_after_all'
910
- python travis_after_all.py

package.json

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,30 @@
55
"license": "MIT",
66
"main": "umd.js",
77
"scripts": {
8-
"test": "npm run lint && nyc --require babel-register mocha -u exports",
8+
"test": "jest",
99
"build": "browserify -t [ babelify --presets [ es2015 ] ] src/ErrorWrapper.js --standalone ErrorWrapper > umd.js",
10-
"lint": "lint src test",
10+
"lint": "eslint src",
1111
"prepublish": "npm run build",
12-
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
12+
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
13+
"precommit": "lint-staged"
1314
},
1415
"repository": {
1516
"type": "git",
1617
"url": "https://github.com/spudly/error-wrapper.git"
1718
},
1819
"dependencies": {
19-
"error-subclass": "^2.0.0"
20+
"error-subclass": "^2.2.0"
2021
},
2122
"devDependencies": {
22-
"@spudly/eslint-config": "^3.0.0",
23+
"@spudly/eslint-config": "^5.0.1",
2324
"babel-preset-es2015": "^6.9.0",
24-
"babel-register": "^6.9.0",
2525
"babelify": "^7.3.0",
26-
"browserify": "^13.0.1",
27-
"chai": "^3.0.0",
28-
"mocha": "^3.0.0",
29-
"nyc": "^10.0.0",
26+
"browserify": "^14.1.0",
27+
"eslint": "^3.18.0",
28+
"husky": "^0.13.2",
29+
"jest": "^19.0.2",
30+
"lint-staged": "^3.4.0",
31+
"prettier": "^0.22.0",
3032
"semantic-release": "^6.3.2"
3133
},
3234
"files": [
@@ -39,5 +41,12 @@
3941
},
4042
"eslintConfig": {
4143
"extends": "@spudly"
44+
},
45+
"lint-staged": {
46+
"*.js": [
47+
"eslint --fix",
48+
"prettier --write --print-width=100 --single-quote --bracket-spacing=false 'src/**/*.js'",
49+
"git add"
50+
]
4251
}
4352
}

src/ErrorWrapper.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@
33
import ErrorSubclass from 'error-subclass';
44

55
class ErrorWrapper extends ErrorSubclass {
6-
76
constructor(message, childError) {
87
super(message);
98
this.childError = childError;
10-
const stack = this.stack;
9+
10+
const stackDescriptor = Object.getOwnPropertyDescriptor(this, 'stack');
11+
const getStack = stackDescriptor.get || (() => stackDescriptor.value);
12+
1113
Object.defineProperty(this, 'stack', {
12-
get() {
13-
return `${stack}\nCaused by: ${this.childError.stack}`;
14-
},
14+
get: () => `${getStack.call(this)}\nCaused by: ${this.childError.stack}`
1515
});
1616
}
17-
1817
}
1918

2019
export default ErrorWrapper;

src/ErrorWrapper.test.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import ErrorWrapper from './ErrorWrapper';
2+
3+
const WRAPPER_MESSAGE = '__MESSAGE__';
4+
const WRAPPED_MESSAGE = '__WRAPPED_MESSAGE__';
5+
const WRAPPED_STACK = '__WRAPPED_STACK__';
6+
7+
class ErrorWrapperSubclass extends ErrorWrapper {}
8+
9+
const originalError = new Error(WRAPPED_MESSAGE);
10+
originalError.stack = WRAPPED_STACK;
11+
12+
test('Subclass of ErrorWrapper can be instantiated', () => {
13+
expect(() => new ErrorWrapperSubclass(WRAPPER_MESSAGE, originalError)).not.toThrow();
14+
});
15+
16+
test('ErrorWrapper Subclass instance should have a name', () => {
17+
const instance = new ErrorWrapperSubclass(WRAPPER_MESSAGE, originalError);
18+
expect(instance.name).toBe('ErrorWrapperSubclass');
19+
});
20+
21+
test('ErrorWrapper Subclass instance should have a childError property', () => {
22+
const instance = new ErrorWrapperSubclass(WRAPPER_MESSAGE, originalError);
23+
expect(instance.childError).toBe(originalError);
24+
});
25+
26+
test('ErrorWrapper Subclass instance should have a stack', () => {
27+
const instance = new ErrorWrapperSubclass(WRAPPER_MESSAGE, originalError);
28+
expect(typeof instance.stack).toBe('string');
29+
expect(instance.stack).toMatch(`ErrorWrapperSubclass: ${WRAPPER_MESSAGE}`);
30+
});
31+
32+
test("ErrorWrapper Subclass instance stack trace contains child's stack trace", () => {
33+
const instance = new ErrorWrapperSubclass(WRAPPER_MESSAGE, originalError);
34+
expect(instance.stack).toMatch(`\nCaused by: ${WRAPPED_STACK}`);
35+
});
36+
37+
test('ErrorWrapper Subclass instance should have a message', () => {
38+
const instance = new ErrorWrapperSubclass(WRAPPER_MESSAGE, originalError);
39+
expect(instance.message).toBe(WRAPPER_MESSAGE);
40+
});
41+
42+
test('ErrorWrapper Subclass instance has a toString() method', () => {
43+
const instance = new ErrorWrapperSubclass(WRAPPER_MESSAGE, originalError);
44+
expect(typeof instance.toString).toBe('function');
45+
expect(instance.toString()).toBe(`ErrorWrapperSubclass: ${WRAPPER_MESSAGE}`);
46+
});

test/ErrorWrapperTest.js

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)