mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-14 15:49:31 -07:00
update test to mjs
This commit is contained in:
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@@ -69,13 +69,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Test",
|
"name": "Test",
|
||||||
"program": "${workspaceFolder}/tests/index.js",
|
"program": "${workspaceFolder}/tests/index.mjs",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"skipFiles": [
|
"skipFiles": [
|
||||||
"<node_internals>/**"
|
"<node_internals>/**"
|
||||||
],
|
],
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"outputCapture": "std"
|
"console": "integratedTerminal"
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"compounds": [
|
"compounds": [
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/* eslint-disable import/no-extraneous-dependencies */
|
/* eslint-disable import/no-extraneous-dependencies */
|
||||||
|
import 'dotenv/config';
|
||||||
import {
|
import {
|
||||||
src, dest, series, parallel,
|
src, dest, series, parallel,
|
||||||
} from 'gulp';
|
} from 'gulp';
|
||||||
@@ -32,8 +33,6 @@ const jsSourcesData = [
|
|||||||
|
|
||||||
const webpackOptions = {
|
const webpackOptions = {
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
// mode: 'development',
|
|
||||||
// devtool: 'source-map',
|
|
||||||
output: {
|
output: {
|
||||||
filename: 'ws.min.js',
|
filename: 'ws.min.js',
|
||||||
},
|
},
|
||||||
@@ -138,7 +137,7 @@ const uploadSources = [
|
|||||||
];
|
];
|
||||||
const upload = () => src(uploadSources, { base: './dist', encoding: false })
|
const upload = () => src(uploadSources, { base: './dist', encoding: false })
|
||||||
.pipe(s3({
|
.pipe(s3({
|
||||||
Bucket: 'weatherstar',
|
Bucket: process.env.BUCKET,
|
||||||
StorageClass: 'STANDARD',
|
StorageClass: 'STANDARD',
|
||||||
maps: {
|
maps: {
|
||||||
CacheControl: (keyname) => {
|
CacheControl: (keyname) => {
|
||||||
@@ -156,13 +155,13 @@ const imageSources = [
|
|||||||
const uploadImages = () => src(imageSources, { base: './server', encoding: false })
|
const uploadImages = () => src(imageSources, { base: './server', encoding: false })
|
||||||
.pipe(
|
.pipe(
|
||||||
s3({
|
s3({
|
||||||
Bucket: 'weatherstar',
|
Bucket: process.env.BUCKET,
|
||||||
StorageClass: 'STANDARD',
|
StorageClass: 'STANDARD',
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const invalidate = () => cloudfront.send(new CreateInvalidationCommand({
|
const invalidate = () => cloudfront.send(new CreateInvalidationCommand({
|
||||||
DistributionId: 'E9171A4KV8KCW',
|
DistributionId: process.env.DISTRIBUTION_ID,
|
||||||
InvalidationBatch: {
|
InvalidationBatch: {
|
||||||
CallerReference: (new Date()).toLocaleString(),
|
CallerReference: (new Date()).toLocaleString(),
|
||||||
Paths: {
|
Paths: {
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
const puppeteer = require('puppeteer');
|
|
||||||
const { setTimeout } = require('node:timers/promises');
|
|
||||||
const { readFile } = require('fs/promises');
|
|
||||||
const messageFormatter = require('./messageformatter');
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
const browser = await puppeteer.launch({
|
|
||||||
// headless: false,
|
|
||||||
slowMo: 10,
|
|
||||||
timeout: 10_000,
|
|
||||||
dumpio: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
// get the list of locations
|
|
||||||
const LOCATIONS = JSON.parse(await readFile('./tests/locations.json'));
|
|
||||||
|
|
||||||
// get the page
|
|
||||||
const page = (await browser.pages())[0];
|
|
||||||
await page.goto('http://localhost:8080');
|
|
||||||
|
|
||||||
page.on('console', messageFormatter);
|
|
||||||
|
|
||||||
// run all the locations
|
|
||||||
for (let i = 0; i < LOCATIONS.length; i += 1) {
|
|
||||||
const location = LOCATIONS[i];
|
|
||||||
console.log(location);
|
|
||||||
// eslint-disable-next-line no-await-in-loop
|
|
||||||
await tester(location, page);
|
|
||||||
}
|
|
||||||
|
|
||||||
browser.close();
|
|
||||||
})();
|
|
||||||
|
|
||||||
const tester = async (location, page) => {
|
|
||||||
// Set the address
|
|
||||||
await page.type('#txtAddress', location);
|
|
||||||
await setTimeout(500);
|
|
||||||
// get the page
|
|
||||||
await page.click('#btnGetLatLng');
|
|
||||||
// wait for errors
|
|
||||||
await setTimeout(5000);
|
|
||||||
};
|
|
||||||
40
tests/index.mjs
Normal file
40
tests/index.mjs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import puppeteer from 'puppeteer';
|
||||||
|
import { setTimeout } from 'node:timers/promises';
|
||||||
|
import { readFile } from 'fs/promises';
|
||||||
|
import messageFormatter from './messageformatter.mjs';
|
||||||
|
|
||||||
|
const browser = await puppeteer.launch({
|
||||||
|
// headless: false,
|
||||||
|
slowMo: 10,
|
||||||
|
timeout: 10_000,
|
||||||
|
dumpio: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// get the list of locations
|
||||||
|
const LOCATIONS = JSON.parse(await readFile('./tests/locations.json'));
|
||||||
|
|
||||||
|
// get the page
|
||||||
|
const page = (await browser.pages())[0];
|
||||||
|
await page.goto('http://localhost:8080');
|
||||||
|
|
||||||
|
page.on('console', messageFormatter);
|
||||||
|
|
||||||
|
const tester = async (location, testPage) => {
|
||||||
|
// Set the address
|
||||||
|
await testPage.type('#txtAddress', location);
|
||||||
|
await setTimeout(500);
|
||||||
|
// get the page
|
||||||
|
await testPage.click('#btnGetLatLng');
|
||||||
|
// wait for errors
|
||||||
|
await setTimeout(5000);
|
||||||
|
};
|
||||||
|
|
||||||
|
// run all the locations
|
||||||
|
for (let i = 0; i < LOCATIONS.length; i += 1) {
|
||||||
|
const location = LOCATIONS[i];
|
||||||
|
console.log(location);
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
await tester(location, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
browser.close();
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
const chalk = require('chalk');
|
import chalk from 'chalk';
|
||||||
|
|
||||||
const describe = (jsHandle) => jsHandle.executionContext().evaluate(
|
const describe = (jsHandle) => jsHandle.evaluate(
|
||||||
// serialize |obj| however you want
|
// serialize |obj| however you want
|
||||||
(obj) => `OBJ: ${typeof obj}, ${obj}`,
|
(obj) => `OBJ: ${typeof obj}, ${obj}`,
|
||||||
jsHandle,
|
jsHandle,
|
||||||
@@ -25,4 +25,4 @@ const formatter = async (message) => {
|
|||||||
console.log(color(`CONSOLE.${type}: ${message.text()}\n${text} `));
|
console.log(color(`CONSOLE.${type}: ${message.text()}\n${text} `));
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = formatter;
|
export default formatter;
|
||||||
1757
tests/package-lock.json
generated
1757
tests/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "ws4kp-tests",
|
"name": "ws4kp-tests",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Currently, tests take a different approach from typical unit testing. The test methodology loads several forecasts for different locations and logs them all to one logger so errors can be found such as missing icons, locations that do not have all of the necessary data or other changes that may occur between geographical locations.",
|
"description": "Currently, tests take a different approach from typical unit testing. The test methodology loads several forecasts for different locations and logs them all to one logger so errors can be found such as missing icons, locations that do not have all of the necessary data or other changes that may occur between geographical locations.",
|
||||||
"main": "index.js",
|
"main": "index.mjs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^4.0.0",
|
"chalk": "^5.4.1",
|
||||||
"puppeteer": "^19.5.2"
|
"puppeteer": "^24.8.2"
|
||||||
}
|
},
|
||||||
|
"type": "module"
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,8 @@
|
|||||||
"Tucsan",
|
"Tucsan",
|
||||||
"Malek",
|
"Malek",
|
||||||
"mwood",
|
"mwood",
|
||||||
"unmuted"
|
"unmuted",
|
||||||
|
"dumpio"
|
||||||
],
|
],
|
||||||
"cSpell.ignorePaths": [
|
"cSpell.ignorePaths": [
|
||||||
"**/package-lock.json",
|
"**/package-lock.json",
|
||||||
|
|||||||
Reference in New Issue
Block a user