<commit_before>// 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 {expectedErrors} from '../../conductor/hooks.js';
import {getBrowserAndPages, goToResource, step} from '../../shared/helper.js';
import {describe, it} from '../../shared/mocha-extensions.js';

describe('Assertions', async function() {
  // Test flaky on Mac
  it.skipOnPlatforms(['mac'], '[crbug.com/1183321]: console.assert', async () => {
    const {frontend} = getBrowserAndPages();
    await step('Check the evaluation results from console', async () => {
      frontend.evaluate(() => {
        console.assert(false, 'expected failure 1');
      });
    });
    await goToResource('cross_tool/default.html');
    assert.ok(expectedErrors.some(error => error.includes('expected failure 1')));
  });

  // Flaky test
  it.skip('[crbug.com/1145969]: console.error', async () => {
    const {frontend} = getBrowserAndPages();
    await step('Check the evaluation results from console', async () => {
      frontend.evaluate(() => {
        function foo() {
          console.error('expected failure 2');
        }
        foo();
      });
    });
    await goToResource('cross_tool/default.html');
    assert.ok(expectedErrors.some(error => error.includes('expected failure 2')));
  });
});
<commit_msg>Enable flaky assertion tests<commit_after>// 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 {expectedErrors} from '../../conductor/hooks.js';
import {getBrowserAndPages, goToResource, step} from '../../shared/helper.js';
import {describe, it} from '../../shared/mocha-extensions.js';

describe('Assertions', async function() {
  it('console.assert', async () => {
    const {frontend} = getBrowserAndPages();
    await step('Check the evaluation results from console', async () => {
      await frontend.evaluate(() => {
        console.assert(false, 'expected failure 1');
      });
    });
    await goToResource('cross_tool/default.html');
    assert.ok(expectedErrors.some(error => error.includes('expected failure 1')));
  });

  it('console.error', async () => {
    const {frontend} = getBrowserAndPages();
    await step('Check the evaluation results from console', async () => {
      await frontend.evaluate(() => {
        function foo() {
          console.error('expected failure 2');
        }
        foo();
      });
    });
    await goToResource('cross_tool/default.html');
    assert.ok(expectedErrors.some(error => error.includes('expected failure 2')));
  });
});

{'fraction_non_alphanumeric': 0.16340579710144928, 'fraction_numerical': 0.010869565217391304, 'mean_word_length': 3.3617693522906795, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4875414', 'n_tokens_mistral': 801, 'n_tokens_neox': 775, 'n_words': 214}