html-browser-tester 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser-test.d.ts +3 -0
- package/lib/browser-test.js +2 -1
- package/lib/expect/assert.d.ts +1 -0
- package/lib/expect/assert.js +11 -0
- package/package.json +1 -1
package/lib/browser-test.d.ts
CHANGED
@@ -7,6 +7,7 @@ declare type Option = {
|
|
7
7
|
declare type Result = {
|
8
8
|
description: string;
|
9
9
|
result: boolean;
|
10
|
+
error?: unknown;
|
10
11
|
};
|
11
12
|
export declare class BrowserTester {
|
12
13
|
private html;
|
@@ -41,6 +42,7 @@ export declare class BrowserTester {
|
|
41
42
|
toBeInstanceOf: (...value: unknown[]) => void;
|
42
43
|
toHaveBeenCalled: (...value: unknown[]) => void;
|
43
44
|
toHaveBeenCalledWith: (...value: unknown[]) => void;
|
45
|
+
toThrow: (...value: unknown[]) => void;
|
44
46
|
} & {
|
45
47
|
not: {
|
46
48
|
toBe: (...value: unknown[]) => void;
|
@@ -59,6 +61,7 @@ export declare class BrowserTester {
|
|
59
61
|
toBeInstanceOf: (...value: unknown[]) => void;
|
60
62
|
toHaveBeenCalled: (...value: unknown[]) => void;
|
61
63
|
toHaveBeenCalledWith: (...value: unknown[]) => void;
|
64
|
+
toThrow: (...value: unknown[]) => void;
|
62
65
|
};
|
63
66
|
};
|
64
67
|
clearTests(): void;
|
package/lib/browser-test.js
CHANGED
@@ -59,7 +59,7 @@ class BrowserTester {
|
|
59
59
|
}
|
60
60
|
evaluate(code) {
|
61
61
|
const func = new Function('test', 'it', 'expect', 'beforeEach', 'afterEach', 'setBrowserSize', 'spyOn', code);
|
62
|
-
func(this.test.bind(this), this.it.bind(this), this.expect.bind(this), this.beforeEach.bind(this), this.afterEach.bind(this), this.setBrowserSize.bind(this), this.spyOn
|
62
|
+
func(this.test.bind(this), this.it.bind(this), this.expect.bind(this), this.beforeEach.bind(this), this.afterEach.bind(this), this.setBrowserSize.bind(this), this.spyOn);
|
63
63
|
}
|
64
64
|
run() {
|
65
65
|
return new Promise((resolve) => {
|
@@ -93,6 +93,7 @@ class BrowserTester {
|
|
93
93
|
results.push({
|
94
94
|
description,
|
95
95
|
result: false,
|
96
|
+
error: e,
|
96
97
|
});
|
97
98
|
}
|
98
99
|
this.expects.clean();
|
package/lib/expect/assert.d.ts
CHANGED
package/lib/expect/assert.js
CHANGED
@@ -90,6 +90,17 @@ const assert = (expected) => ({
|
|
90
90
|
return expected.calledArgs.some(arg => {
|
91
91
|
return arg.every((a, i) => a === args[i]);
|
92
92
|
});
|
93
|
+
},
|
94
|
+
toThrow: () => {
|
95
|
+
try {
|
96
|
+
if (typeof expected === 'function') {
|
97
|
+
expected();
|
98
|
+
}
|
99
|
+
}
|
100
|
+
catch (e) {
|
101
|
+
return true;
|
102
|
+
}
|
103
|
+
return false;
|
93
104
|
}
|
94
105
|
});
|
95
106
|
exports.assert = assert;
|