mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-02 18:11:04 +08:00
This CL bans the TS `!` operator which is used to assert not null. Typically when we use this we are making errors harder to track down should the value actually end up being null. Checking it takes more work but will give nicer errors. Fixed: 1154182 Change-Id: I11599541c199204e4ca21c9fd81a256614d70389 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2566804 Commit-Queue: Jack Franklin <jacktfranklin@chromium.org> Reviewed-by: Alex Rudenko <alexrudenko@chromium.org> Reviewed-by: Paul Lewis <aerotwist@chromium.org>
52 lines
2.2 KiB
TypeScript
52 lines
2.2 KiB
TypeScript
// Copyright 2020 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import {assert} from 'chai';
|
|
|
|
import {click, getBrowserAndPages, step} from '../../shared/helper.js';
|
|
import {describe, it} from '../../shared/mocha-extensions.js';
|
|
import {CONSOLE_TAB_SELECTOR, focusConsolePrompt, typeIntoConsole, typeIntoConsoleAndWaitForResult} from '../helpers/console-helpers.js';
|
|
|
|
describe('The Console Tab', async function() {
|
|
it('is cleared via the console.clear() method', async () => {
|
|
const {frontend} = getBrowserAndPages();
|
|
await click(CONSOLE_TAB_SELECTOR);
|
|
await focusConsolePrompt();
|
|
|
|
await step('enter 1 in console', async () => {
|
|
await typeIntoConsoleAndWaitForResult(frontend, '1;');
|
|
});
|
|
await step('enter 2 in console', async () => {
|
|
await typeIntoConsoleAndWaitForResult(frontend, '2;');
|
|
});
|
|
await step('enter 3 in console', async () => {
|
|
await typeIntoConsoleAndWaitForResult(frontend, '3;');
|
|
});
|
|
await step('Check the evaluation results from console', async () => {
|
|
const evaluateResults = await frontend.evaluate(() => {
|
|
return Array.from(document.querySelectorAll('.console-user-command-result')).map(node => node.textContent);
|
|
});
|
|
assert.deepEqual(evaluateResults, ['1', '2', '3'], 'did not find expected output in the console');
|
|
});
|
|
await step('enter console.clear() in console', async () => {
|
|
await typeIntoConsole(frontend, 'console.clear();');
|
|
});
|
|
await step('wait for the console to be cleared', async () => {
|
|
await frontend.waitForFunction(() => {
|
|
return document.querySelectorAll('.console-user-command-result').length === 1;
|
|
});
|
|
});
|
|
await step('check that the remaining text in the console is correct', async () => {
|
|
const clearResult = await frontend.evaluate(() => {
|
|
const result = document.querySelector('.console-user-command-result');
|
|
if (!result) {
|
|
assert.fail('Could not find user command result in the DOM.');
|
|
}
|
|
return result.textContent;
|
|
});
|
|
assert.strictEqual(clearResult, 'undefined', 'the result of clear was not undefined');
|
|
});
|
|
});
|
|
});
|