Test Profiles


Test Profiles allow you to change the conditions that your site is tested under. In this guide we’ll demonstrate how to create and manage Test Profiles with the CLI and Node.js API.

Create a Test Profile

Required API Permission: Create Test Profiles
1calibre site create-test-profile "<name>" --site <site>
1#!/usr/bin/env node
2
3const { TestProfile } = require('calibre')
4
5const create = async () => {
6 const profileParams = {
7 site: 'calibre',
8 name: 'Chrome Desktop',
9 cookies: [
10 {
11 name: 'app.sid',
12 value: 'sessionId',
13 domain: 'calibreapp.com',
14 path: '/',
15 secure: true,
16 httpOnly: true
17 }
18 ],
19 headers: [
20 {
21 name: 'Authorization',
22 value: 'Bearer 1234567890'
23 }
24 ]
25 }
26
27 try {
28 const profile = await TestProfile.create(profileParams)
29
30 console.log('Created', profile)
31 } catch (e) {
32 console.error(e)
33 }
34}
35
36create()
ParameterRequiredDescription
siteYesSite slug, found in Site settings.
nameYesA descriptive name given to the Test Profile.
deviceNoA Device tag sets the device emulation used for tests. Use the `calibre device-list` command for a list of options.
connectionNoA Connection tag sets the network throttling used for tests. Use the `calibre connection-list` command for a list of options.
cookiesNoOne or more cookies (array of hashes).
headersNoOne or many headers (array of hashes).
adblockerNoTurn on uBlock Adblock extension. Boolean. Default: false.
javascriptNoJavaScript Requests Allowed. Boolean. Default: true.

Update a Test Profile

Required API Permission: Update Test Profiles
1calibre site update-test-profile --uuid <uuid> --site <site>
1#!/usr/bin/env node
2
3const { TestProfile } = require('calibre')
4
5const update = async () => {
6 const profileParams = {
7 site: 'calibre',
8 uuid: 'a47e812c-853a-4167-969f-7dd143eb213d',
9 name: 'Adblocker on',
10 adblocker: true
11 }
12
13 try {
14 const profile = await TestProfile.update(profileParams)
15
16 console.log('Updated', profile)
17 } catch (e) {
18 console.error(e)
19 }
20}
21
22update()
ParameterRequiredDescription
uuidYesThe uuid of the Test Profile.
siteYesSite slug, found in Site settings.
nameNoA descriptive name given to the Test Profile.
deviceNoA Device tag sets the device emulation used for tests. Use the `calibre device-list` command for a list of options.
connectionNoA Connection tag sets the network throttling used for tests. Use the `calibre connection-list` command for a list of options.
cookiesNoOne or more cookies (array of hashes).
headersNoOne or many headers (array of hashes).
adblockerNoTurn on uBlock Adblock extension. Boolean. Default: false.
javascriptNoJavaScript Requests Allowed. Boolean. Default: true.

List Test Profiles

Required API Permission: Read Sites
1calibre site test-profiles --site <site>
1#!/usr/bin/env node
2
3const { TestProfile } = require('calibre')
4
5const list = async () => {
6 try {
7 const profiles = await TestProfile.list({
8 site: 'calibre'
9 })
10
11 console.log(profiles)
12 } catch (e) {
13 console.error(e)
14 }
15}
16
17list()
ParameterRequiredDescription
siteYesSite slug, found in Site settings.

Delete a Test Profile

Caution
This is a dangerous and irreversible action. Deleting a Test Profile will also remove all corresponding test data.
Required API Permission: Delete Test Profiles
1calibre site delete-test-profile --uuid <uuid> --site <site> --confirm
1#!/usr/bin/env node
2
3const { TestProfile } = require('calibre')
4
5const destroyProfile = async () => {
6 const profileParams = {
7 site: 'calibre',
8 uuid: '3803a1ba-a9ec-417f-9673-5571d31325a8'
9 }
10
11 try {
12 const profile = await TestProfile.destroy(profileParams)
13
14 console.log('Deleted', profile)
15 } catch (e) {
16 console.error(e)
17 }
18}
19
20destroyProfile()
ParameterRequiredDescription
nameNoA descriptive name given to the Test Profile.
uuidYesThe uuid of the Test Profile.
siteYesSite slug, found in Site settings.