Ошибка: протокол JSON Ошибка API при запуске Lighthouse с TestCafe Server - PullRequest
0 голосов
/ 15 апреля 2020

Я пытаюсь написать код, который будет ускорять TestCafe Server, войти на аутентифицированную страницу, перейти на нужную страницу и затем выполнить Lighthouse для этой страницы.

Вот мой testcafeServer. js file:

const createTestCafe = require('testcafe'); let testcafe = null; createTestCafe('localhost', 1337, 1338) .then((tc) => { testcafe = tc; const runner = testcafe.createRunner(); return runner.src(['test_lightHouse.js']).browsers(['chrome']).run(); }) .then((failedCount) => { console.log('Tests failed: ' + failedCount); testcafe.close(); });

Вот мой тестовый маяк. js file:

import { Selector } from 'testcafe'; var fs = require('fs'); const lighthouse = require('lighthouse'); fixture`LightHouse Test`.page( 'MY-SPECIFIC-URL' ); test(`Generate Light House Result `, async (t) => { //Specific code to navigate to a certain page const auditResult = await lighthouse( 'MY-CURRENT-URL-I-WANT-TO-TEST', { logLevel: 'info', output: 'html', port: 1337, //I am getting this port # from the TestCafe server I am standing up locally - might be wrong } ); // Write data in 'Output.txt' . fs.writeFile('mynewfile3.html', auditResult, function (err) { if (err) throw err; console.log('Saved!'); }); console.log(auditResult); });

При выполнении этого кода я получить следующую ошибку:

✖ Generate Light House Result 1) Error: Protocol JSON API error (list), status: 404 Browser: Chrome 80.0.3987.163 / macOS 10.15.4 102 | return resolve({message: data}); 103 | } 104 | return reject(e); 105 | } 106 | } > 107 | reject(new Error(`Protocol JSON API error (${command}), status: ${response.statusCode}`)); 108 | }); 109 | }); 110 | 111 | // This error handler is critical to ensuring Lighthouse exits cleanly even when Chrome crashes. 112 | // See https://github.com/GoogleChrome/lighthouse/pull/8583.

Что не так? Почему это происходит постоянно? Lighthouse просто не предназначен для работы с TestCafe?

1 Ответ

1 голос
/ 16 апреля 2020

В настоящее время не существует простого способа интеграции маяка с TestCafe. Пожалуйста, отследите следующую проблему в репозитории TestCafe, чтобы получать уведомления о наших результатах: https://github.com/DevExpress/testcafe/issues/3493.

Также вы можете попробовать подход, показанный здесь: { ссылка }, но может некорректно работать со страницами аутентификации.

...