mirror of
https://github.com/snobu/destreamer.git
synced 2026-02-25 15:58:23 +00:00
Move tests to new file
This commit is contained in:
19
BrowserTests.ts
Normal file
19
BrowserTests.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import puppeteer from 'puppeteer';
|
||||||
|
|
||||||
|
export async function BrowserTests() {
|
||||||
|
console.log('[BROWSER TEST] Launching headless Chrome...');
|
||||||
|
const browser = await puppeteer.launch({
|
||||||
|
// Switch to false if you need to login interactively
|
||||||
|
headless: true,
|
||||||
|
args: ['--disable-dev-shm-usage']
|
||||||
|
});
|
||||||
|
const page = await browser.newPage();
|
||||||
|
await page.goto("https://github.com/", { waitUntil: 'networkidle2' });
|
||||||
|
let pageTitle = await page.title();
|
||||||
|
await browser.close();
|
||||||
|
if (!pageTitle.includes('GitHub')) {
|
||||||
|
console.log('[BROWSER TEST] FAIL: Page title does not include "GitHub"');
|
||||||
|
process.exit(44);
|
||||||
|
}
|
||||||
|
console.log('[BROWSER TEST] PASS');
|
||||||
|
}
|
||||||
@@ -3,8 +3,7 @@ import puppeteer from 'puppeteer';
|
|||||||
import { terminal as term } from 'terminal-kit';
|
import { terminal as term } from 'terminal-kit';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { AssertionError } from 'assert';
|
import { BrowserTests } from './BrowserTests';
|
||||||
|
|
||||||
|
|
||||||
// Type in your username here (the one you use to
|
// Type in your username here (the one you use to
|
||||||
// login to Microsoft Stream).
|
// login to Microsoft Stream).
|
||||||
@@ -45,25 +44,6 @@ function sanityChecks() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runBrowserTest() {
|
|
||||||
console.log('[BROWSER TEST] Launching headless Chrome...');
|
|
||||||
const browser = await puppeteer.launch({
|
|
||||||
// Switch to false if you need to login interactively
|
|
||||||
headless: true,
|
|
||||||
args: ['--disable-dev-shm-usage']
|
|
||||||
});
|
|
||||||
const page = await browser.newPage();
|
|
||||||
await page.goto("https://github.com/", { waitUntil: 'networkidle2' });
|
|
||||||
let pageTitle = await page.title();
|
|
||||||
await browser.close();
|
|
||||||
if (!pageTitle.includes('GitHub'))
|
|
||||||
{
|
|
||||||
console.log('[BROWSER TEST] FAIL: Page title does not include "GitHub"');
|
|
||||||
process.exit(44);
|
|
||||||
}
|
|
||||||
console.log('[BROWSER TEST] PASS');
|
|
||||||
}
|
|
||||||
|
|
||||||
async function rentVideoForLater() {
|
async function rentVideoForLater() {
|
||||||
console.log('Launching headless Chrome to perform the OpenID Connect dance...');
|
console.log('Launching headless Chrome to perform the OpenID Connect dance...');
|
||||||
const browser = await puppeteer.launch({
|
const browser = await puppeteer.launch({
|
||||||
@@ -149,7 +129,7 @@ async function exfiltrateCookie(page: puppeteer.Page) {
|
|||||||
// We should probably use Mocha or something
|
// We should probably use Mocha or something
|
||||||
if (args[0] === 'test')
|
if (args[0] === 'test')
|
||||||
{
|
{
|
||||||
runBrowserTest();
|
BrowserTests();
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user