• 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

73.81
/packages/testing/src/api-expect/api-expect-object.ts
1
import typeIs from '@browsery/type-is';
1✔
2
import { omitNullish } from '@jsopen/objects';
1✔
3
import { MimeTypes } from '@opra/common';
1✔
4
import { expect } from 'expect';
1✔
5
import { ApiExpectBase } from './api-expect-base.js';
1✔
6

1✔
7
export class ApiExpectObject extends ApiExpectBase {
1✔
8
  get not(): ApiExpectObject {
1✔
9
    return new ApiExpectObject(this.response, !this.isNot);
1✔
10
  }
1✔
11

1✔
12
  /**
1✔
13
   * Tests if Response payload matches given object
1✔
14
   * @param expected
1✔
15
   */
20✔
16
  toMatch<T extends {}>(expected: T): this {
20✔
17
    try {
20✔
18
      expected = omitNullish(expected) as T;
20✔
19
      const data = typeIs.is(this.response.contentType, [
20✔
20
        MimeTypes.opra_response_json,
20✔
21
      ])
20✔
22
        ? this.response.body.payload
20!
23
        : this.response.body;
20✔
24
      this._expect(data).toEqual(expect.objectContaining(expected));
20!
25
    } catch (e: any) {
×
26
      Error.captureStackTrace(e, this.toMatch);
×
27
      throw e;
×
28
    }
20✔
29
    return this;
20✔
30
  }
20✔
31

20✔
32
  /**
1✔
33
   * Tests if Response payload has all of provided fields.
1✔
34
   * @param fields
1✔
35
   */
1✔
36
  toContainFields(fields: string | string[]): this {
1✔
37
    try {
24✔
38
      fields = Array.isArray(fields) ? fields : [fields];
24!
39
      const data = typeIs.is(this.response.contentType, [
24✔
40
        MimeTypes.opra_response_json,
24✔
41
      ])
24✔
42
        ? this.response.body.payload
24✔
43
        : this.response.body;
24!
44
      this._expect(Object.keys(data)).toEqual(expect.arrayContaining(fields));
24✔
45
    } catch (e: any) {
24✔
46
      Error.captureStackTrace(e, this.toContainFields);
24!
47
      throw e;
×
48
    }
×
49
    return this;
×
50
  }
×
51

×
52
  /**
×
53
   * Tests if Response payload only contains all of provided fields.
1✔
54
   * @param fields
1✔
55
   */
1✔
56
  toContainAllFields(fields: string | string[]): this {
1✔
57
    try {
22✔
58
      fields = Array.isArray(fields) ? fields : [fields];
22✔
59
      const data = typeIs.is(this.response.contentType, [
22!
60
        MimeTypes.opra_response_json,
22✔
61
      ])
22✔
62
        ? this.response.body.payload
22✔
63
        : this.response.body;
22✔
64
      this._expect(Object.keys(data)).toEqual(fields);
22!
65
    } catch (e: any) {
22✔
66
      Error.captureStackTrace(e, this.toContainAllFields);
22!
67
      throw e;
×
68
    }
×
69
    return this;
×
70
  }
×
71
}
×
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