How to use the qunit.testStart function in qunit

To help you get started, we’ve selected a few qunit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emberjs / ember-test-helpers / tests / test-helper.js View on Github external
}

new TestLoader().loadModules();

let deprecations;
registerDeprecationHandler((message, options, next) => {
  // in case a deprecation is issued before a test is started
  if (!deprecations) {
    deprecations = [];
  }

  deprecations.push(message);
  next(message, options);
});

QUnit.testStart(function() {
  deprecations = [];
});

QUnit.testDone(function({ module, name }) {
  run.backburner.DEBUG = true;
  // this is used to ensure that no tests accidentally leak `Ember.testing` state
  if (Ember.testing) {
    let message = `Ember.testing should be reset after test has completed. ${module}: ${name} did not reset Ember.testing`;
    cleanupFailures.push(message);

    // eslint-disable-next-line
    console.error(message);
    Ember.testing = false;
  }

  // this is used to ensure that the testing container is always reset properly
github emberjs / data / packages / unpublished-test-infra / addon-test-support / qunit-asserts / assert-deprecation.ts View on Github external
export function configureDeprecationHandler() {
  if (HAS_REGISTERED === true) {
    throw new Error(`Attempting to re-register the assert-deprecation handler`);
  }
  HAS_REGISTERED = true;

  QUnit.testStart(function() {
    DEPRECATIONS_FOR_TEST = [];
    HANDLED_DEPRECATIONS_FOR_TEST = [];
  });

  registerDeprecationHandler(function(message, options: DeprecationConfig /*, next*/) {
    options.stacktrace = new Error().stack;
    if (DEPRECATIONS_FOR_TEST) {
      DEPRECATIONS_FOR_TEST.push({ message, options });
    }
    // we do not call next to avoid spamming the console
  });

  QUnit.assert.expectDeprecation = async function(
    cb: () => unknown,
    config: string | RegExp | DeprecationConfig,
    label?: string
github workmanw / ember-qunit-assert-helpers / addon-test-support / asserts / warning.js View on Github external
export default function() {
  let warnings;

  QUnit.testStart(function() {
    warnings = [];
  });

  Ember.Debug.registerWarnHandler(function(message, options, next) {
    // It's possible for warnings to trigger before the test has started.
    if (warnings) {
      warnings.push({ message, options });
    }
    next(message, options);
  });

  function assertWarnings(qunitAssert, matcher) {
    let matchedWarnings = warnings.filter(warning => {
      return checkMatcher(warning.message, matcher);
    });
    qunitAssert.pushResult({
github buschtoens / ember-on-modifier / tests / test-helper.js View on Github external
import { start } from 'ember-qunit';
import QUnit from 'qunit';

import require, { has } from 'require';

import Application from '../app';
import config from '../config/environment';
// import { __counts } from 'ember-on-modifier/modifiers/on';

let __counts = null;

if (has('ember-on-modifier/modifiers/on')) {
  __counts = require('ember-on-modifier/modifiers/on').__counts;
}

QUnit.testStart(() => {
  if (__counts !== null) {
    QUnit.config.current.testEnvironment._startingCounts = __counts();
  }
});

QUnit.assert.counts = function(
  expected,
  message = `counters have incremented by ${JSON.stringify(expected)}`
) {
  if (__counts === null) {
    this.ok(true, 'using upstream implementation, not asserting on counts');
    return;
  }

  const current = __counts();
github workmanw / ember-qunit-assert-helpers / addon-test-support / asserts / deprecation.js View on Github external
export default function() {
  let deprecations;

  QUnit.testStart(function() {
    deprecations = [];
  });

  Ember.Debug.registerDeprecationHandler(function(message, options, next) {
    // It's possible for deprecations to trigger before the test has started.
    if (deprecations) {
      deprecations.push({ message, options });
    }
    next(message, options);
  });

  function assertDeprecations(qunitAssert, matcher) {
    let matchedDeprecations = deprecations.filter(deprecation => {
      return checkMatcher(deprecation.message, matcher);
    });
    qunitAssert.pushResult({
github brzpegasus / ember-cli-nwjs / test-support / node-webkit / qunit-logger.js View on Github external
passed: params.result,
                  actual: params.actual,
                  expected: params.expected,
                  message: params.message
              })
          }

      }

      if (params.result !== true) {
        var actualTestCount = results.total + 1;
        log('not ok ' + actualTestCount + ' - ' + params.module + ' - ' + params.name);
      }

  })
  QUnit.testStart( function(params){
      currentTest = {
          id: id++,
          name: (currentModule ? currentModule + ': ' : '') + params.name,
          items: []
      }
      socket.emit('tests-start')
  })
  QUnit.testDone( function(params){
      currentTest.failed = params.failed
      currentTest.passed = params.passed
      currentTest.total = params.total

      results.total++
      if (currentTest.failed > 0)
          results.failed++
      else
github emberjs / ember-qunit / addon-test-support / ember-qunit / index.js View on Github external
export function setupEmberTesting() {
  QUnit.testStart(() => {
    Ember.testing = true;
  });

  QUnit.testDone(() => {
    Ember.testing = false;
  });
}
github rwjblue / ember-getowner-polyfill / tests / test-helper.js View on Github external
import Ember from 'ember';
import QUnit from 'qunit';
import resolver from './helpers/resolver';
import {
  setResolver
} from 'ember-qunit';
import { start } from 'ember-cli-qunit';

let deprecations;
Ember.Debug.registerDeprecationHandler((message, options, next) => {
  deprecations.push(message);
  next(message, options);
});

QUnit.testStart(function() {
  deprecations = [];
});

QUnit.assert.noDeprecationsOccurred = function() {
  this.deepEqual(deprecations, [], 'Expected no deprecations during test.');
};

QUnit.assert.deprecations = function(callback, expectedDeprecations) {
  let originalDeprecations = deprecations;
  deprecations = [];

  callback();
  this.deepEqual(deprecations, expectedDeprecations, 'Expected deprecations during test.');

  deprecations = originalDeprecations;
};
github Addepar / ember-table / tests / test-helper.js View on Github external
import Application from '../app';
import config from '../config/environment';
import registerRAFWaiter from 'ember-raf-scheduler/test-support/register-waiter';
import { setApplication } from '@ember/test-helpers';
import { start } from 'ember-qunit';
import QUnit from 'qunit';
import {
  setup as setupWarnHandlers,
  teardown as teardownWarnHandlers,
} from './helpers/warn-handlers';

registerRAFWaiter();
setApplication(Application.create(config.APP));

QUnit.testStart(() => {
  setupWarnHandlers();
});

QUnit.testDone(() => {
  teardownWarnHandlers();
});

start();