How to use jasmine-core - 10 common examples

To help you get started, we’ve selected a few jasmine-core 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 tensorflow / tfjs / tfjs-react-native / integration_rn59 / components / tfjs_unit_test_runner.tsx View on Github external
const failedTests: FailedTestInfo[] = [];

    // A lot of the code below is adapted from
    // node_modules/jasmine-core/lib/jasmine-core/boot.js
    // it provides a custom way to start jasmine in the RN app.

    // Helper function for adding jasmine functionlaity to global.
    // tslint:disable-next-line: no-any
    function extend(destination: any, source: any) {
      for (const property in source) {
        destination[property] = source[property];
      }
      return destination;
    }

    const jasmine = jasmineRequire.core(jasmineRequire);
    // @ts-ignore
    global.jasmine = jasmine;
    const env: jasmine.Env = jasmine.getEnv();

    const jasmineInterface = jasmineRequire.interface(jasmine, env);
    extend(global, jasmineInterface);

    //@ts-ignore
    env.configure({ random: false });

    // Custom reporter to collect the test results
    const reactReporter: jasmine.CustomReporter = {
      jasmineStarted: suiteInfo => {
        // The console.warn below seems necessary in order for the spy on
        // console.warn defined in one of the tests to run corrently.
        console.warn('starting tests');
github tensorflow / tfjs / tfjs-react-native / integration_rn59 / components / tfjs_unit_test_runner.tsx View on Github external
// Helper function for adding jasmine functionlaity to global.
    // tslint:disable-next-line: no-any
    function extend(destination: any, source: any) {
      for (const property in source) {
        destination[property] = source[property];
      }
      return destination;
    }

    const jasmine = jasmineRequire.core(jasmineRequire);
    // @ts-ignore
    global.jasmine = jasmine;
    const env: jasmine.Env = jasmine.getEnv();

    const jasmineInterface = jasmineRequire.interface(jasmine, env);
    extend(global, jasmineInterface);

    //@ts-ignore
    env.configure({ random: false });

    // Custom reporter to collect the test results
    const reactReporter: jasmine.CustomReporter = {
      jasmineStarted: suiteInfo => {
        // The console.warn below seems necessary in order for the spy on
        // console.warn defined in one of the tests to run corrently.
        console.warn('starting tests');
        //@ts-ignore
        console.reportErrorsAsExceptions = false;
        this.setState({
          testsStarted: true,
          totalTests: suiteInfo.totalSpecsDefined,
github expo / expo / apps / test-suite / screens / TestScreen.js View on Github external
async _setupJasmine() {
    // Init
    jasmineModule.DEFAULT_TIMEOUT_INTERVAL = 10000;
    const jasmineCore = jasmineModule.core(jasmineModule);
    const jasmineEnv = jasmineCore.getEnv();

    // Add our custom reporters too
    jasmineEnv.addReporter(this._jasmineSetStateReporter());
    jasmineEnv.addReporter(this._jasmineConsoleReporter());

    // Get the interface and make it support `async ` by default
    const jasmine = jasmineModule.interface(jasmineCore, jasmineEnv);
    const doneIfy = fn => async done => {
      try {
        await Promise.resolve(fn());
        done();
      } catch (e) {
        done.fail(e);
      }
    };
github expo / expo / apps / test-suite / utils / setupJasmine.js View on Github external
export default async function setupJasmine(app, onStart, onComplete) {
  // Init
  jasmineModule.DEFAULT_TIMEOUT_INTERVAL = 10000;
  const jasmineCore = jasmineModule.core(jasmineModule);
  const jasmineEnv = jasmineCore.getEnv();

  // Add our custom reporters too
  jasmineEnv.addReporter(jasmineSetStateReporter(app, onStart, onComplete));
  jasmineEnv.addReporter(jasmineConsoleReporter(app));

  // Get the interface and make it support `async ` by default
  const jasmine = jasmineModule.interface(jasmineCore, jasmineEnv);
  const doneIfy = fn => async done => {
    try {
      await fn();
      done();
    } catch (e) {
      done.fail(e);
    }
  };
github expo / expo / apps / test-suite / utils / setupJasmine.js View on Github external
export default async function setupJasmine(app, onStart, onComplete) {
  // Init
  jasmineModule.DEFAULT_TIMEOUT_INTERVAL = 10000;
  const jasmineCore = jasmineModule.core(jasmineModule);
  const jasmineEnv = jasmineCore.getEnv();

  // Add our custom reporters too
  jasmineEnv.addReporter(jasmineSetStateReporter(app, onStart, onComplete));
  jasmineEnv.addReporter(jasmineConsoleReporter(app));

  // Get the interface and make it support `async ` by default
  const jasmine = jasmineModule.interface(jasmineCore, jasmineEnv);
  const doneIfy = fn => async done => {
    try {
      await fn();
      done();
    } catch (e) {
      done.fail(e);
    }
  };
  const oldIt = jasmine.it;
  jasmine.it = (desc, fn, t) => oldIt.apply(jasmine, [desc, doneIfy(fn), t]);
  const oldXit = jasmine.xit;
  jasmine.xit = (desc, fn, t) => oldXit.apply(jasmine, [desc, doneIfy(fn), t]);
  const oldFit = jasmine.fit;
  jasmine.fit = (desc, fn, t) => oldFit.apply(jasmine, [desc, doneIfy(fn), t]);

  return {
github expo / expo / apps / test-suite / screens / TestScreen.js View on Github external
async _setupJasmine() {
    // Init
    jasmineModule.DEFAULT_TIMEOUT_INTERVAL = 10000;
    const jasmineCore = jasmineModule.core(jasmineModule);
    const jasmineEnv = jasmineCore.getEnv();

    // Add our custom reporters too
    jasmineEnv.addReporter(this._jasmineSetStateReporter());
    jasmineEnv.addReporter(this._jasmineConsoleReporter());

    // Get the interface and make it support `async ` by default
    const jasmine = jasmineModule.interface(jasmineCore, jasmineEnv);
    const doneIfy = fn => async done => {
      try {
        await Promise.resolve(fn());
        done();
      } catch (e) {
        done.fail(e);
      }
    };
    const oldIt = jasmine.it;
    jasmine.it = (desc, fn, t) => oldIt.apply(jasmine, [desc, doneIfy(fn), t]);
    const oldXit = jasmine.xit;
    jasmine.xit = (desc, fn, t) => oldXit.apply(jasmine, [desc, doneIfy(fn), t]);
    const oldFit = jasmine.fit;
    jasmine.fit = (desc, fn, t) => oldFit.apply(jasmine, [desc, doneIfy(fn), t]);

    return {
github montagejs / montage / test / run-node.js View on Github external
/*jshint node:true, browser:false */
var jasmineRequire = require('jasmine-core/lib/jasmine-core/jasmine.js');
var JasmineConsoleReporter = require('jasmine-console-reporter');
var Montage = require('../montage');
var PATH = require("path");
global.XMLHttpRequest = require('xhr2');
// Init
var jasmine = jasmineRequire.core(jasmineRequire);
var jasmineEnv = jasmine.getEnv();
    
// Export interface
var jasmineInterface = jasmineRequire.interface(jasmine, jasmineEnv);
global.jasmine = jasmine;
global.jasmineRequire = jasmineRequire;
for (var property in jasmineInterface) {
    if (jasmineInterface.hasOwnProperty(property)) {
       global[property] = jasmineInterface[property];
    }
} 

// Default reporter
jasmineEnv.addReporter(jasmineInterface.jsApiReporter);

// Html reporter
github montagejs / collections / test / run-node.js View on Github external
/*jshint node:true, browser:false */
var jasmineRequire = require('jasmine-core/lib/jasmine-core/jasmine.js');
var JasmineConsoleReporter = require('jasmine-console-reporter');

// Init
var jasmine = jasmineRequire.core(jasmineRequire);
var jasmineEnv = jasmine.getEnv();
    
// Export interface
var jasmineInterface = jasmineRequire.interface(jasmine, jasmineEnv);
global.jasmine = jasmine;
global.jasmineRequire = jasmineRequire;
for (var property in jasmineInterface) {
    if (jasmineInterface.hasOwnProperty(property)) {
       global[property] = jasmineInterface[property];
    }
} 

// Default reporter
jasmineEnv.addReporter(jasmineInterface.jsApiReporter);

// Html reporter
github montagejs / digit / test / run-node.js View on Github external
/*jshint node:true, browser:false */
var jasmineRequire = require('jasmine-core/lib/jasmine-core/jasmine.js');
var JasmineConsoleReporter = require('jasmine-console-reporter');
var Montage = require('montage');
var PATH = require("path");

// Init
var jasmine = jasmineRequire.core(jasmineRequire);
var jasmineEnv = jasmine.getEnv();
    
// Export interface
var jasmineInterface = jasmineRequire.interface(jasmine, jasmineEnv);
global.jasmine = jasmine;
global.jasmineRequire = jasmineRequire;
for (var property in jasmineInterface) {
    if (jasmineInterface.hasOwnProperty(property)) {
       global[property] = jasmineInterface[property];
    }
} 

// Default reporter
jasmineEnv.addReporter(jasmineInterface.jsApiReporter);

// Html reporter
github montagejs / mr / test / run-node.js View on Github external
/*jshint node:true, browser:false */
var jasmineRequire = require('jasmine-core/lib/jasmine-core/jasmine.js');
var JasmineConsoleReporter = require('jasmine-console-reporter');

// Init
var jasmine = jasmineRequire.core(jasmineRequire);
var jasmineEnv = jasmine.getEnv();
    
// Export interface
var jasmineInterface = jasmineRequire.interface(jasmine, jasmineEnv);
global.jasmine = jasmine;
global.jasmineRequire = jasmineRequire;
for (var property in jasmineInterface) {
    if (jasmineInterface.hasOwnProperty(property)) {
       global[property] = jasmineInterface[property];
    }
} 

// Default reporter
jasmineEnv.addReporter(jasmineInterface.jsApiReporter);

// Html reporter