@postmate/core 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-postmate-core.d.ts","sourceRoot":"","sources":["../src/test-postmate-core.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { CoreContext } from './coreContext.js';
|
|
3
|
+
import { ApiEngine } from './engine/apiEngine.js';
|
|
4
|
+
const data = {
|
|
5
|
+
"username": "m4@mithilaschool.com",
|
|
6
|
+
"password": "Test@123",
|
|
7
|
+
"region": "TUP",
|
|
8
|
+
"accountNumber": "123456,234"
|
|
9
|
+
};
|
|
10
|
+
const postmateRequest = {
|
|
11
|
+
url: "{{baseurl_school}}/student",
|
|
12
|
+
method: "GET",
|
|
13
|
+
id: "a7725168-d409-4ce8-aabd-b856a99c8917",
|
|
14
|
+
name: "getStudents-schema-test",
|
|
15
|
+
collectionId: "c777fea3-5b84-46d6-bbf7-2422eb68f05f",
|
|
16
|
+
containerId: "9cf11ba8-6d3d-4bc7-9c45-497e4eeefe74",
|
|
17
|
+
collectionName: "school",
|
|
18
|
+
bodyFormat: "json",
|
|
19
|
+
body: {
|
|
20
|
+
json: {}
|
|
21
|
+
},
|
|
22
|
+
preRequests: [],
|
|
23
|
+
data: data,
|
|
24
|
+
testScript: "// const foo = 'bar';\nconsole.log(1);\npm.test(\"Verify response status 200\", () => {\n assert.equal(RESPONSE.status, '200');\n});\npm.test(\"Verify school Name is ABC Learning Academy\", () => {\n assert.equal(RESPONSE.body.schoolInof.schoolName, 'ABC Learning Academy ');\n});\n\npm.setVariable(\"a\", 2999);\npm.setVariable(\"b\", 1);\n\npm.test(\"Verify response status 200\", () => {\n assert.equal(RESPONSE.status, '200');\n});\n\n\nconst arr = [\"\\\"123\\\"\", \"\\\"4345\\\"\"];\npm.setVariable('myArr', arr);\nconsole.log(pm.getVariable('myArr'));\n\n\n//=============extra\npm.test(\"Verify response status 200\", () => {\n assert.equal(RESPONSE.status, '200');\n});\npm.test(\"Verify school Name is ABC Learning Academy\", () => {\n assert.equal(RESPONSE.body.schoolInof.schoolName, 'ABC Learning Academy ');\n});\npm.test(\"Verify response status 200\", () => {\n assert.equal(RESPONSE.status, '200');\n});\npm.test(\"Verify school Name is ABC Learning Academy\", () => {\n assert.equal(RESPONSE.body.schoolInof.schoolName, 'ABC Learning Academy ');\n});\npm.test(\"Verify response status 200\", () => {\n assert.equal(RESPONSE.status, '200');\n});\npm.test(\"Verify school Name is ABC Learning Academy\", () => {\n assert.equal(RESPONSE.body.schoolInof.schoolName, 'ABC Learning Academy ');\n});\npm.test(\"Verify response status 200\", () => {\n assert.equal(RESPONSE.status, '200');\n});\npm.test(\"Verify school Name is ABC Learning Academy\", () => {\n assert.equal(RESPONSE.body.schoolInof.schoolName, 'ABC Learning Academy ');\n});\npm.test(\"Verify response status 200\", () => {\n assert.equal(RESPONSE.status, '200');\n});\npm.test(\"Verify school Name is ABC Learning Academy\", () => {\n assert.equal(RESPONSE.body.schoolInof.schoolName, 'ABC Learning Academy ');\n});\npm.test(\"Verify response status 200\", () => {\n assert.equal(RESPONSE.status, '200');\n});\npm.test(\"Verify school Name is ABC Learning Academy\", () => {\n assert.equal(RESPONSE.body.schoolInof.schoolName, 'ABC Learning Academy ');\n});\npm.test(\"Verify response status 200\", () => {\n assert.equal(RESPONSE.status, '200');\n});\npm.test(\"Verify school Name is ABC Learning Academy Verify school Name is ABC Learning Academy Verify school Name is ABC Learning Academy\", () => {\n assert.equal(RESPONSE.body.schoolInof.schoolName, 'ABC Learning Academy ');\n});\npm.test(\"Verify response status 200\", () => {\n assert.equal(RESPONSE.status, '200');\n});\npm.test(\"Verify school Name is ABC Learning Academy\", () => {\n assert.equal(RESPONSE.body.schoolInof.schoolName, 'ABC Learning Academy ');\n});\n\nconst sampleData = {\n name: \"Shyam\",\n age: 30,\n email: \"shyam@example.com\"\n};\n\n// JSON Schema\nconst userSchema = {\n \"type\": \"object\",\n \"properties\": {\n \"userProfile\": {\n \"type\": \"object\",\n \"properties\": {\n \"fullName\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"fullName\"\n ]\n },\n \"schoolInof\": {\n \"type\": \"object\",\n \"properties\": {\n \"schoolName\": {\n \"type\": \"string\"\n },\n \"isAutoInvoice\": {\n \"type\": \"boolean\"\n },\n \"invoiceDate\": {\n \"type\": \"integer\"\n },\n \"grades\": {\n \"type\": \"null\"\n }\n },\n \"required\": [\n \"schoolName\",\n \"isAutoInvoice\",\n \"invoiceDate\",\n \"grades\"\n ]\n },\n \"students\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"studentId\": {\n \"type\": \"integer\"\n },\n \"rollNumber\": {\n \"type\": \"null\"\n },\n \"name\": {\n \"type\": \"string\"\n },\n \"grade\": {\n \"type\": \"string\"\n },\n \"status\": {\n \"type\": [\n \"string\",\n \"null\"\n ]\n },\n \"paymentStatus\": {\n \"type\": \"string\"\n },\n \"school\": {\n \"type\": \"null\"\n }\n },\n \"required\": [\n \"studentId\",\n \"rollNumber\",\n \"name\",\n \"grade\",\n \"status\",\n \"paymentStatus\",\n \"school\"\n ]\n }\n }\n },\n \"required\": [\n \"userProfile\",\n \"schoolInof\",\n \"students\"\n ]\n}\n\n\npm.schemaTest(\"Validate user data with schemaTest helper\", userSchema, RESPONSE.body);\n",
|
|
25
|
+
preRequestScript: "//@ts-ignore\r\nconst tokenResp = await pm.getRequest('school-11.client').send();\r\nconst jsonBody = JSON.parse(tokenResp.body);\r\n// pm.setVariable('token',jsonBody.accessToken);",
|
|
26
|
+
headers: {
|
|
27
|
+
Accept: "*/*",
|
|
28
|
+
"User-Agent": "Postmate (postmatelab.com)",
|
|
29
|
+
Authorization: "Bearer {{token}}"
|
|
30
|
+
},
|
|
31
|
+
auth: {
|
|
32
|
+
type: "none"
|
|
33
|
+
},
|
|
34
|
+
tests: [
|
|
35
|
+
{
|
|
36
|
+
"testType": "Set Env Variable",
|
|
37
|
+
"testTypeValue": "$.schoolInof.schoolName",
|
|
38
|
+
"action": "set to",
|
|
39
|
+
"expectedValue": "schoolname",
|
|
40
|
+
"testScenario": "Store school name in env variable for later use"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"testType": "In The Response Body",
|
|
44
|
+
"testTypeValue": "$.schoolInof.schoolName",
|
|
45
|
+
"action": "contains",
|
|
46
|
+
"expectedValue": "ABC Learning Academy",
|
|
47
|
+
"testScenario": "Verify school name is correct ABC Learning Academy in the respose"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"testType": "In The Response Body",
|
|
51
|
+
"testTypeValue": "$.schoolInof.isAutoInvoice",
|
|
52
|
+
"action": "equal",
|
|
53
|
+
"expectedValue": "true",
|
|
54
|
+
"testScenario": "Verfiy AutoInvoice is ture in response"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
};
|
|
58
|
+
const coreLogger = {
|
|
59
|
+
onRequestStart(info) {
|
|
60
|
+
logRequest({
|
|
61
|
+
url: info.url,
|
|
62
|
+
method: info.method,
|
|
63
|
+
headers: info.headers,
|
|
64
|
+
body: info.body,
|
|
65
|
+
originalBody: info.originalBody
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
onRequestEnd(info) {
|
|
69
|
+
console.log('------------------Response------------------');
|
|
70
|
+
console.log(`Status : ${info.status}`);
|
|
71
|
+
console.log(`Time : ${info.responseTime} ms`);
|
|
72
|
+
console.log(`headers: ${JSON.stringify(info.headers, null, 2)}`);
|
|
73
|
+
console.log(`body: ${info.body}`);
|
|
74
|
+
},
|
|
75
|
+
onScriptLog(msg) {
|
|
76
|
+
console.log(msg);
|
|
77
|
+
},
|
|
78
|
+
onScriptError(msg) {
|
|
79
|
+
console.log(msg);
|
|
80
|
+
},
|
|
81
|
+
onScriptWarn(msg) {
|
|
82
|
+
console.log(msg);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
function logRequest(info) {
|
|
86
|
+
console.log('-------------Request-----------------');
|
|
87
|
+
console.log('URL: ', info.url);
|
|
88
|
+
console.log('method: ', info.method);
|
|
89
|
+
console.log('headers: ', info.headers);
|
|
90
|
+
console.log('body: ', info.body);
|
|
91
|
+
}
|
|
92
|
+
async function main() {
|
|
93
|
+
let baseDir = path.resolve(process.cwd(), 'postmate-data');
|
|
94
|
+
baseDir = 'C:\\Users\\11shy\\AppData\\Roaming\\Code\\User\\globalStorage\\postmate';
|
|
95
|
+
const logger = {
|
|
96
|
+
onRequestStart: info => console.log(info),
|
|
97
|
+
onRequestEnd: info => console.log(info.status),
|
|
98
|
+
onScriptLog: info => coreLogger.onScriptLog(info),
|
|
99
|
+
onScriptError: info => console.log(info),
|
|
100
|
+
onScriptWarn: info => console.log(info),
|
|
101
|
+
};
|
|
102
|
+
const context = new CoreContext({
|
|
103
|
+
baseDir,
|
|
104
|
+
logger
|
|
105
|
+
});
|
|
106
|
+
const api = new ApiEngine(context.envManager, context.scriptEngine, context.collectionManager, context.variableStore, coreLogger);
|
|
107
|
+
const result = await api.executeRequestWithPrerequests(postmateRequest);
|
|
108
|
+
}
|
|
109
|
+
main().catch(console.error);
|
|
110
|
+
//# sourceMappingURL=test-postmate-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-postmate-core.js","sourceRoot":"","sources":["../src/test-postmate-core.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,MAAM,IAAI,GAAG;IACT,UAAU,EAAE,sBAAsB;IAClC,UAAU,EAAE,UAAU;IACtB,QAAQ,EAAE,KAAK;IACf,eAAe,EAAE,YAAY;CAChC,CAAC;AAEF,MAAM,eAAe,GAAG;IACpB,GAAG,EAAE,4BAA4B;IACjC,MAAM,EAAE,KAAK;IACb,EAAE,EAAE,sCAAsC;IAC1C,IAAI,EAAE,yBAAyB;IAC/B,YAAY,EAAE,sCAAsC;IACpD,WAAW,EAAE,sCAAsC;IACnD,cAAc,EAAE,QAAQ;IACxB,UAAU,EAAE,MAAM;IAClB,IAAI,EAAE;QACF,IAAI,EAAE,EAAE;KACX;IACD,WAAW,EAAE,EAAE;IACf,IAAI,EAAE,IAAI;IACV,UAAU,EAAE,ukJAAukJ;IACnlJ,gBAAgB,EAAE,uLAAuL;IACzM,OAAO,EAAE;QACL,MAAM,EAAE,KAAK;QACb,YAAY,EAAE,4BAA4B;QAC1C,aAAa,EAAE,kBAAkB;KACpC;IACD,IAAI,EAAE;QACF,IAAI,EAAE,MAAM;KACf;IACD,KAAK,EAAE;QACH;YACI,UAAU,EAAE,kBAAkB;YAC9B,eAAe,EAAE,yBAAyB;YAC1C,QAAQ,EAAE,QAAQ;YAClB,eAAe,EAAE,YAAY;YAC7B,cAAc,EAAE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