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.
Required API Permission: Create Test Profiles
Copy Code
1 calibre site create-test-profile "<name>" --site < site >
Copy Code
1
2
3 import { TestProfile } from 'calibre'
4
5 const 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
36 create ( )
Parameter Required Description site Yes Site slug, found in Site settings. name Yes A descriptive name given to the Test Profile. device No A Device tag sets the device emulation used for tests. Use the `calibre device-list` command for a list of options. connection No A Connection tag sets the network throttling used for tests. Use the `calibre connection-list` command for a list of options. cookies No One or more cookies (array of hashes). headers No One or many headers (array of hashes). adblocker No Turn on uBlock Adblock extension. Boolean. Default: false. javascript No JavaScript Requests Allowed. Boolean. Default: true.
Required API Permission: Update Test Profiles
Copy Code
1 calibre site update-test-profile --uuid < uuid > --site < site >
Copy Code
1
2
3 import { TestProfile } from 'calibre'
4
5 const 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
22 update ( )
Parameter Required Description uuid Yes The uuid of the Test Profile. site Yes Site slug, found in Site settings. name No A descriptive name given to the Test Profile. device No A Device tag sets the device emulation used for tests. Use the `calibre device-list` command for a list of options. connection No A Connection tag sets the network throttling used for tests. Use the `calibre connection-list` command for a list of options. cookies No One or more cookies (array of hashes). headers No One or many headers (array of hashes). adblocker No Turn on uBlock Adblock extension. Boolean. Default: false. javascript No JavaScript Requests Allowed. Boolean. Default: true.
Required API Permission: Read Sites
Copy Code
1 calibre site test-profiles --site < site >
Copy Code
1
2
3 import { TestProfile } from 'calibre'
4
5 const 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
17 list ( )
Parameter Required Description site Yes Site slug, found in Site settings.
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
Copy Code
1 calibre site delete-test-profile --uuid < uuid > --site < site > --confirm
Copy Code
1
2
3 import { TestProfile } from 'calibre'
4
5 const 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
20 destroyProfile ( )
Parameter Required Description name No A descriptive name given to the Test Profile. uuid Yes The uuid of the Test Profile. site Yes Site slug, found in Site settings.