Skip to content
On this page

withCore

To further customize the request, pactum allows us directly set the core options of the request.

Syntax

js
withCore(options)

Usage

โœ… Correct Usage

js
await spec()
  .get('/api/users')
  .withCore({
    agent: myAgent
  })
  .expectStatus(200);

Arguments

> options (object)

Core options - see

Examples

Basic Authentication using Core Options

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

await spec()
  .get('https://httpbin.org/basic-auth/user/pass')
  .withCore({
    auth: 'user:pass'
  })
  .expectStatus(200);

Proxy Agent

js
const { spec } = require('pactum');
const { ProxyAgent } = require('proxy-agent');

const agent = new ProxyAgent();

await spec()
  .get('https://pactumjs.github.io/')
  .withCore({ agent })
  .expectStatus(200);

Released under the MIT License.