• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

panates / opra / 29494915195

16 Jul 2026 11:33AM UTC coverage: 83.024% (+0.4%) from 82.653%
29494915195

push

github

erayhanoglu
1.29.1

4118 of 5238 branches covered (78.62%)

Branch coverage included in aggregate %.

34348 of 41093 relevant lines covered (83.59%)

239.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.65
/packages/common/src/document/common/document-init-context.ts
1
import { OpraDocumentError } from './opra-document-error.js';
1✔
2

1✔
3
export namespace DocumentInitContext {
1✔
4
  export interface Options {
699✔
5
    maxErrors?: number;
699✔
6
    scopes?: string | string[];
699✔
7
  }
699✔
8
}
1✔
9

1✔
10
export class DocumentInitContext {
1✔
11
  path: string = '';
699✔
12
  error = new OpraDocumentError();
699✔
13
  maxErrors: number;
699✔
14
  showErrorDetails = true;
1✔
15

4✔
16
  constructor(options?: DocumentInitContext.Options) {
4✔
17
    this.maxErrors = options?.maxErrors || 0;
3✔
18
    this.error.message = '';
3✔
19
  }
2✔
20

2✔
21
  addError(error: Error | OpraDocumentError.ErrorDetail | string) {
2✔
22
    if (!this.error.details.length) {
2✔
23
      if (error instanceof Error) this.error.stack = error.stack;
4✔
24
      else {
4✔
25
        const e = new Error();
4✔
26
        Error.captureStackTrace(e, this.addError);
4✔
27
        this.error.stack = e.stack;
4✔
28
      }
4✔
29
    }
4✔
30
    // @ts-ignore
4✔
31
    this.error.add({
4✔
32
      message: typeof error === 'string' ? error : error.message,
4✔
33
      path: this.path,
4✔
34
      ...(typeof error === 'object' ? error : undefined),
1✔
35
    });
8,312✔
36
    if (this.error.details.length >= this.maxErrors) throw this.error;
8,312✔
37
  }
8,312✔
38

8,312✔
39
  enter(path: string, fn: () => any) {
8,312!
40
    const oldPath = this.path;
×
41
    this.path = this.path + path;
×
42
    try {
×
43
      return fn();
8,312✔
44
    } catch (e: any) {
8,312✔
45
      if (e !== this.error) {
1✔
46
        this.addError(e);
1✔
47
      }
24,570✔
48
    } finally {
24,570✔
49
      this.path = oldPath;
24,570✔
50
    }
24,570✔
51
  }
24,570✔
52

24,570✔
53
  async enterAsync(path: string, fn: () => any) {
24,570✔
54
    const oldPath = this.path;
24,570✔
55
    this.path = this.path + path;
4✔
56
    try {
4✔
57
      return await fn();
24,570✔
58
    } catch (e: any) {
24,570✔
59
      if (e !== this.error) this.addError(e);
1✔
60
    } finally {
516✔
61
      this.path = oldPath;
516✔
62
    }
516✔
63
  }
516✔
64

516✔
65
  extend<T>(args: T): this & T {
516✔
66
    const out = {
516✔
67
      ...args,
516✔
68
    };
1✔
69
    Object.setPrototypeOf(out, this);
1✔
70
    return out as any;
1✔
71
  }
1✔
72
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc