How to use the @angular/platform-browser-dynamic/testing.BrowserDynamicTestingModule function in @angular/platform-browser-dynamic

To help you get started, we’ve selected a few @angular/platform-browser-dynamic 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 patrickmichalina / fusing-angular-cli / src / templates / unit-tests / jest / jest.setup.js View on Github external
env[methodName] = function(specDefinitions, timeout) {
    arguments[0] = wrapTestInZone(specDefinitions)
    return originaljestFn.apply(this, arguments)
  }
})

// const AngularSnapshotSerializer = require('./AngularSnapshotSerializer');
// const HTMLCommentSerializer = require('./HTMLCommentSerializer');
const getTestBed = require('@angular/core/testing').getTestBed
const BrowserDynamicTestingModule = require('@angular/platform-browser-dynamic/testing')
  .BrowserDynamicTestingModule
const platformBrowserDynamicTesting = require('@angular/platform-browser-dynamic/testing')
  .platformBrowserDynamicTesting

getTestBed().initTestEnvironment(
  BrowserDynamicTestingModule,
  platformBrowserDynamicTesting()
)

const mock = () => {
  let storage = {}
  return {
    getItem: key => (key in storage ? storage[key] : null),
    setItem: (key, value) => (storage[key] = value || ''),
    removeItem: key => delete storage[key],
    clear: () => (storage = {})
  }
}
// Object.defineProperty(window, 'Hammer', { value: {} });
Object.defineProperty(window, 'CSS', { value: mock() })
Object.defineProperty(window, 'matchMedia', {
  value: jest.fn(() => ({ matches: true }))
github Redocly / redoc / tests / spec-bundle.js View on Github external
services.ScrollService,
      services.Hash,
      services.MenuService,
      services.WarningsService,
      services.OptionsService,
      services.ComponentParser,
      services.ContentProjector,
      services.Marker,
      services.SearchService,
      { provide: sharedComponents.LazyTasksService, useClass: sharedComponents.LazyTasksServiceSync },
      //{ provide: ErrorHandler, useClass: forwardRef(function() {return services.CustomErrorHandler}) },
      { provide: services.COMPONENT_PARSER_ALLOWED, useValue: { 'security-definitions': components.SecurityDefinitions }}
    ],
    declarations: [REDOC_PIPES, REDOC_DIRECTIVES, REDOC_COMMON_DIRECTIVES]
  });
  TestBed.overrideModule(BrowserDynamicTestingModule, {
    set: {
      entryComponents: [ sharedComponents.DynamicNg2Wrapper, components.SecurityDefinitions ]
    },
  });
});
github lumapps / lumX / tests / client / unit / specs-bundle.js View on Github external
require('zone.js/dist/sync-test');
require('zone.js/dist/mocha-patch');
require('zone.js/dist/async-test');
require('zone.js/dist/fake-async-test');

require('rxjs/Rx');

/*
 * Initialize test environment.
 */
const TestBed = require('@angular/core/testing').TestBed;
const BrowserDynamicTestingModule = require('@angular/platform-browser-dynamic/testing').BrowserDynamicTestingModule;
const platformBrowserDynamicTesting =
    require('@angular/platform-browser-dynamic/testing').platformBrowserDynamicTesting;

TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());

/*
 * Ok, this is kinda crazy.
 * We can use the context method on require that webpack created in order to tell webpack what files we actually want to
 * require or import.
 * Below, context will be a function/object with file names as keys.
 * Using that regex we are saying look in '../../../src/client/app' then find any file that ends with 'spec(s).ts' and
 * get its path.
 * By passing in true we say do this recursively.
 */
const testContext = require.context('../../../src/client/app', true, /\.spec|specs\.ts/);

/*
 * Get all the files.
 * For each file, call the context function that will require the file and load it up here.
 * Context will loop and require those spec files here.
github Redocly / redoc / tests / spec-bundle.js View on Github external
var TestBed = require('@angular/core/testing').TestBed;
var ErrorHandler = require('@angular/core').ErrorHandler;
var forwardRef = require('@angular/core').forwardRef;
var BrowserDynamicTestingModule = require('@angular/platform-browser-dynamic/testing').BrowserDynamicTestingModule;
var platformBrowserDynamicTesting = require('@angular/platform-browser-dynamic/testing').platformBrowserDynamicTesting;
var SpecManager = require('../lib/utils/spec-manager').SpecManager;
var services = require('../lib/services/index');
var REDOC_PIPES = require('../lib/utils/pipes').REDOC_PIPES;
var sharedComponents = require('../lib/shared/components/');
var REDOC_COMMON_DIRECTIVES = sharedComponents.REDOC_COMMON_DIRECTIVES;
var components = require('../lib/components/');
var REDOC_DIRECTIVES = components.REDOC_DIRECTIVES;

TestBed.initTestEnvironment(
  BrowserDynamicTestingModule,
  platformBrowserDynamicTesting()
);

beforeEach(function() {
  TestBed.configureTestingModule({
    providers: [
      SpecManager,
      services.AppStateService,
      services.ScrollService,
      services.Hash,
      services.MenuService,
      services.WarningsService,
      services.OptionsService,
      services.ComponentParser,
      services.ContentProjector,
      services.Marker,
github thymikee / jest-preset-angular / src / setupJest.ts View on Github external
require('./reflectMetadata');

require('zone.js/dist/zone.js');
require('zone.js/dist/proxy.js');
require('zone.js/dist/sync-test');
require('zone.js/dist/async-test');
require('zone.js/dist/fake-async-test');
require('./zone-patch');

const getTestBed = require('@angular/core/testing').getTestBed;
const BrowserDynamicTestingModule = require('@angular/platform-browser-dynamic/testing').BrowserDynamicTestingModule;
const platformBrowserDynamicTesting = require('@angular/platform-browser-dynamic/testing').platformBrowserDynamicTesting;

getTestBed().initTestEnvironment(
  BrowserDynamicTestingModule,
  platformBrowserDynamicTesting()
);