Skip to content
On this page

withCompression

Enables compression of gzip, deflate and brotli(br) encoded data.

Syntax

js
withCompression()

Usage

โœ… Correct Usage

js
await spec()
  .get('/api/file')
  .withCompression()
  .expectStatus(200);

Examples

Brotli Compression

js
const { spec } = require('pactum');

await spec()
  .get('https://httpbin.org/brotli')
  .withCompression()
  .expectStatus(200);

Deflate Compression

js
const { spec } = require('pactum');

await spec()
  .get('https://httpbin.org/deflate')
  .withCompression()
  .expectStatus(200);

GZip Compression

js
const { spec } = require('pactum');

await spec()
  .get('https://httpbin.org/gzip')
  .withCompression()
  .expectStatus(200);

Released under the MIT License.