This repository has been archived by the owner on Sep 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
demo.ts
55 lines (52 loc) · 1.44 KB
/
demo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { runTestScript } from "./index"
import { TestResponse } from "./test-runner"
const dummyResponse: TestResponse = {
status: 200,
body: "hoi",
headers: []
};
// eslint-disable-next-line prettier/prettier
(async () => {
console.dir(
await runTestScript(
`
pw.test("Arithmetic operations and toBe", () => {
const size = 500 + 500;
pw.expect(size).toBe(1000);
pw.expect(size - 500).toBe(500);
pw.expect(size * 4).toBe(4000);
pw.expect(size / 4).toBe(250);
});
pw.test("toBeLevelxxx", () => {
pw.expect(200).toBeLevel2xx();
pw.expect(204).toBeLevel2xx();
pw.expect(300).not.toBeLevel2xx();
pw.expect(300).toBeLevel3xx();
pw.expect(304).toBeLevel3xx();
pw.expect(204).not.toBeLevel3xx();
pw.expect(401).toBeLevel4xx();
pw.expect(404).toBeLevel4xx();
pw.expect(204).not.toBeLevel4xx();
pw.expect(501).toBeLevel5xx();
pw.expect(504).toBeLevel5xx();
pw.expect(204).not.toBeLevel5xx();
});
pw.test("toBeType", () => {
pw.expect("hello").toBeType("string");
pw.expect(10).toBeType("number");
pw.expect(true).toBeType("boolean");
pw.expect("deffonotanumber").not.toBeType("number");
});
pw.test("toHaveLength", () => {
const arr = [1, 2, 3];
pw.expect(arr).toHaveLength(3);
pw.expect(arr).not.toHaveLength(4);
});
`,
dummyResponse
),
{
depth: 100,
}
)
})()