lint
This commit is contained in:
parent
aeee592507
commit
6fc18b6935
|
|
@ -2,9 +2,9 @@ name: AWS Lambda CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [master]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [master]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
@ -52,7 +52,7 @@ jobs:
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: "3.x"
|
||||||
|
|
||||||
- name: Setup AWS SAM CLI
|
- name: Setup AWS SAM CLI
|
||||||
uses: aws-actions/setup-sam@v2
|
uses: aws-actions/setup-sam@v2
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ jobs:
|
||||||
name: Build and release
|
name: Build and release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
# Install jq so I can edit package.json from the command line
|
# Install jq so I can edit package.json from the command line
|
||||||
- run: sudo apt-get install jq -y
|
- run: sudo apt-get install jq -y
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
const { ok } = require('assert');
|
const { ok } = require("assert");
|
||||||
const { createHash } = require('crypto');
|
const { createHash } = require("crypto");
|
||||||
const puppeteer = require("puppeteer-core");
|
const puppeteer = require("puppeteer-core");
|
||||||
const chromium = require('@sparticuz/chromium');
|
const chromium = require("@sparticuz/chromium");
|
||||||
|
|
||||||
exports.handler = async (event, context) => {
|
exports.handler = async (event, context) => {
|
||||||
let browser = null;
|
let browser = null;
|
||||||
|
|
@ -15,9 +15,9 @@ exports.handler = async (event, context) => {
|
||||||
ignoreHTTPSErrors: true,
|
ignoreHTTPSErrors: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const contexts = [
|
console.log("Chromium verion", await browser.version());
|
||||||
browser.defaultBrowserContext(),
|
|
||||||
];
|
const contexts = [browser.defaultBrowserContext()];
|
||||||
|
|
||||||
while (contexts.length < event.length) {
|
while (contexts.length < event.length) {
|
||||||
contexts.push(await browser.createIncognitoBrowserContext());
|
contexts.push(await browser.createIncognitoBrowserContext());
|
||||||
|
|
@ -27,23 +27,31 @@ exports.handler = async (event, context) => {
|
||||||
const job = event.shift();
|
const job = event.shift();
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
|
|
||||||
if (job.hasOwnProperty('url') === true) {
|
if (job.hasOwnProperty("url") === true) {
|
||||||
await page.goto(job.url, { waitUntil: ['domcontentloaded', 'load'] });
|
await page.goto(job.url, { waitUntil: ["domcontentloaded", "load"] });
|
||||||
|
|
||||||
if (job.hasOwnProperty('expected') === true) {
|
if (job.hasOwnProperty("expected") === true) {
|
||||||
if (job.expected.hasOwnProperty('title') === true) {
|
if (job.expected.hasOwnProperty("title") === true) {
|
||||||
ok(await page.title() === job.expected.title, `Title assertion failed.`);
|
ok(
|
||||||
|
(await page.title()) === job.expected.title,
|
||||||
|
`Title assertion failed.`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (job.expected.hasOwnProperty('screenshot') === true) {
|
if (job.expected.hasOwnProperty("screenshot") === true) {
|
||||||
if (job.expected.hasOwnProperty('remove') === true) {
|
if (job.expected.hasOwnProperty("remove") === true) {
|
||||||
await page.evaluate((selector) => {
|
await page.evaluate((selector) => {
|
||||||
document.getElementById(selector).remove();
|
document.getElementById(selector).remove();
|
||||||
}, job.expected.remove);
|
}, job.expected.remove);
|
||||||
}
|
}
|
||||||
const screenshot = await page.screenshot();
|
const screenshot = await page.screenshot();
|
||||||
// console.log(screenshot.toString('base64'), createHash('sha1').update(screenshot.toString('base64')).digest('hex'));
|
// console.log(screenshot.toString('base64'), createHash('sha1').update(screenshot.toString('base64')).digest('hex'));
|
||||||
ok(createHash('sha1').update(screenshot.toString('base64')).digest('hex') === job.expected.screenshot, `Screenshot assertion failed.`);
|
ok(
|
||||||
|
createHash("sha1")
|
||||||
|
.update(screenshot.toString("base64"))
|
||||||
|
.digest("hex") === job.expected.screenshot,
|
||||||
|
`Screenshot assertion failed.`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,10 @@
|
||||||
{
|
{
|
||||||
"extends": [
|
"extends": ["@tsconfig/node16/tsconfig", "@tsconfig/strictest"],
|
||||||
"@tsconfig/node16/tsconfig",
|
|
||||||
"@tsconfig/strictest"
|
|
||||||
],
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"lib": [
|
"lib": ["dom", "ES2021"],
|
||||||
"dom"
|
|
||||||
],
|
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"outDir": "build",
|
"outDir": "build"
|
||||||
},
|
},
|
||||||
"include": [
|
"include": ["source"]
|
||||||
"source"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue