Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 59feaf0c07 | |||
| f20eaa875c | |||
| 6e27497f14 |
@@ -1,5 +0,0 @@
|
|||||||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
|
||||||
module.exports = {
|
|
||||||
preset: 'ts-jest',
|
|
||||||
testEnvironment: 'node',
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
transaction.png
|
||||||
|
node_modules/
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"name": "sdk_wasm_tests",
|
||||||
|
"version": "1.0.2",
|
||||||
|
"license": "ISC",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha --timeout 10000 --require ts-node/register src/tests/*.spec.ts",
|
||||||
|
"build": "npm run",
|
||||||
|
"testlocal": "npm run build && npm run test"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"prettier": "^2.8.4",
|
||||||
|
"puppeteer": "^19.7.5"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/chai": "^4.2.18",
|
||||||
|
"@types/mocha": "^10.0.1",
|
||||||
|
"@types/node": "^18.15.3",
|
||||||
|
"@types/puppeteer": "^7.0.4",
|
||||||
|
"chai": "^4.3.4",
|
||||||
|
"mocha": "^10.2.0",
|
||||||
|
"mochawesome": "^7.1.3",
|
||||||
|
"puppeteer-debug": "^2.0.0",
|
||||||
|
"ts-node": "^10.0.0",
|
||||||
|
"typescript": "^4.3.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"localhost": "http://localhost:3000/"
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"sender": "#sender",
|
||||||
|
"recipient": "#recipient",
|
||||||
|
"id": "#message",
|
||||||
|
"send_button": "#send-button",
|
||||||
|
"output": "#output"
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { expect } from 'chai';
|
||||||
|
const selectors = require('../selectors/attr.json');
|
||||||
|
import kermit from '../utils/kermit';
|
||||||
|
const config = require('../config/config.json');
|
||||||
|
import delay from '../utils/helper';
|
||||||
|
|
||||||
|
describe('run base test', async () => {
|
||||||
|
let browser;
|
||||||
|
let page;
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
browser = await kermit();
|
||||||
|
page = await browser.newPage();
|
||||||
|
await page.goto(config.localhost);
|
||||||
|
await delay(5000);
|
||||||
|
});
|
||||||
|
|
||||||
|
after(async () => {
|
||||||
|
await page.screenshot({ path: 'transaction.png' });
|
||||||
|
await browser.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Validate an address can be pasted', async () => {
|
||||||
|
const senderaddress = await page.evaluate(() => {
|
||||||
|
return (document.querySelector('#sender') as HTMLInputElement).value;
|
||||||
|
});
|
||||||
|
await page.type(selectors.recipient, senderaddress);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Validate a mesage can be typed', async () => {
|
||||||
|
await page.click(selectors.id, { clickCount: 3 });
|
||||||
|
await page.type(selectors.id, "Hi, I'm a test");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Validate the message can be sent and received', async () => {
|
||||||
|
await page.click(selectors.send_button);
|
||||||
|
await delay(1500);
|
||||||
|
|
||||||
|
const sentmessage = await page.evaluate(() => {
|
||||||
|
return (document.querySelector('#output') as Element).firstChild.textContent;
|
||||||
|
});
|
||||||
|
const receivedmesage = await page.evaluate(() => {
|
||||||
|
return (document.querySelector('#output') as Element).lastChild.textContent;
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(receivedmesage);
|
||||||
|
console.log(sentmessage);
|
||||||
|
expect(receivedmesage).contains('received');
|
||||||
|
expect(sentmessage).contains('sent');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export default async function delay(time) {
|
||||||
|
return new Promise(function (resolve) {
|
||||||
|
setTimeout(resolve, time);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import * as puppeteer from 'puppeteer';
|
||||||
|
|
||||||
|
const defaultOptions = {
|
||||||
|
headless: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default async (options = undefined) => {
|
||||||
|
const puppeterOptions = options === undefined ? defaultOptions : options;
|
||||||
|
return await puppeteer.launch(puppeterOptions);
|
||||||
|
};
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es6",
|
||||||
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"removeComments": true,
|
||||||
|
"noImplicitAny": false
|
||||||
|
},
|
||||||
|
"include": ["src/tests/*.spec.ts"]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user