mirror of
https://github.com/Kong/insomnia.git
synced 2026-04-21 14:47:46 -04:00
test(scripting): check using external libs in the critical test suite
This commit is contained in:
@@ -1077,3 +1077,40 @@ resources:
|
||||
text: |-
|
||||
{}
|
||||
_type: request
|
||||
- _id: req_89dade2ee9ee42fbb22d588783a9df16
|
||||
parentId: fld_01de564274824ecaad272330339ea6b2
|
||||
modified: 1636707449231
|
||||
created: 1636141014552
|
||||
url: http://127.0.0.1:4010/echo
|
||||
name: use external modules
|
||||
description: ""
|
||||
method: POST
|
||||
parameters: []
|
||||
headers:
|
||||
- name: 'Content-Type'
|
||||
value: 'application/json'
|
||||
authentication: {}
|
||||
metaSortKey: -1636141014553
|
||||
isPrivate: false
|
||||
settingStoreCookies: true
|
||||
settingSendCookies: true
|
||||
settingDisableRenderRequestBody: false
|
||||
settingEncodeUrl: true
|
||||
settingRebuildPath: true
|
||||
settingFollowRedirects: global
|
||||
preRequestScript: |-
|
||||
const ajv = require("ajv")
|
||||
const chai = require('chai');
|
||||
const lodash = require('lodash');
|
||||
const tv4 = require('tv4');
|
||||
const uuid = require('uuid');
|
||||
const xml2js = require('xml2js');
|
||||
const csv = require('csv-parse/lib/sync');
|
||||
const cheerio = require('cheerio');
|
||||
const crypto = require('crypto-js');
|
||||
const moment = require('moment');
|
||||
body:
|
||||
mimeType: "application/json"
|
||||
text: |-
|
||||
{}
|
||||
_type: request
|
||||
|
||||
@@ -36,3 +36,26 @@ test('can use node-libcurl, httpsnippet, hidden browser window', async ({ app, p
|
||||
await expect(statusTag).toContainText('200 OK');
|
||||
await page.getByRole('tab', { name: 'Timeline' }).click();
|
||||
});
|
||||
|
||||
test('can use external modules in scripts ', async ({ app, page }) => {
|
||||
const text = await loadFixture('pre-request-collection.yaml');
|
||||
|
||||
// import collection
|
||||
await app.evaluate(async ({ clipboard }, text) => clipboard.writeText(text), text);
|
||||
await page.getByRole('button', { name: 'Create in project' }).click();
|
||||
await page.getByRole('menuitemradio', { name: 'Import' }).click();
|
||||
await page.locator('[data-test-id="import-from-clipboard"]').click();
|
||||
await page.getByRole('button', { name: 'Scan' }).click();
|
||||
await page.getByRole('dialog').getByRole('button', { name: 'Import' }).click();
|
||||
|
||||
// select request
|
||||
await page.getByLabel('Pre-request Scripts').click();
|
||||
await page.getByLabel('Request Collection').getByTestId('use external modules').press('Enter');
|
||||
|
||||
// send
|
||||
await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click();
|
||||
|
||||
// verify
|
||||
const statusTag = page.locator('[data-testid="response-status-tag"]:visible');
|
||||
await expect(statusTag).toContainText('200 OK');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user