Debian Codegraph @

browsertests/testdata/testfixture.js

raw symbols SCIP
1 // TestFixture records log messages and errors in an array that will
2 // be returned to Go code. Each element in the result array is either
3 // an array of the form ["LOG", ...], or ["ERROR", ...].
4 class TestFixture {
5 constructor() {
6 this.context = ""; // Added to front of all log and error messages.
7 this.result = [];
8 }
9
10 run(name, subtest) {
11 this.result.push(["LOG", "===", name]);
12 this.context = "";
13 subtest();
14 this.context = "";
15 }
16
17 // setContext arranges to add name(args) to all messages added
18 // until the next setContext or run call.
19 setContext(name, ...args) {
20 this.context = name + "(" + args.join(",") + ")";
21 }
22
23 log(...args) {
24 this.result.push(["LOG", this.context, ...args]);
25 }
26
27 err(...args) {
28 this.result.push(["ERROR", this.context, ...args]);
29 }
30 }