How to use the @angular/platform-server/testing.platformServerTesting function in @angular/platform-server

To help you get started, we’ve selected a few @angular/platform-server 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 ngrx / platform / tests.js View on Github external
global.jasmine = runner.jasmine;

require('zone.js/dist/jasmine-patch.js');

// Override console.warn, otherwise we log too much to the console
// This is because of the `runtimeChecks` warning when no runtime config is provided
console.warn = () => {};

const { getTestBed } = require('@angular/core/testing');
const {
  ServerTestingModule,
  platformServerTesting,
} = require('@angular/platform-server/testing');

getTestBed().initTestEnvironment(ServerTestingModule, platformServerTesting());

runner.loadConfig({
  spec_dir: 'modules',
  spec_files: ['**/*.spec.ts'],
});

runner.execute();
github angular-redux / platform / packages / store / tests.js View on Github external
// or bad things happen when users of this package try to use MockNgRedux etc. This bit of code
// gets the unit test process to alias `import '@angular-redux/store'` to `import `../src` during
// our unit test execution.
const tsconfigPaths = require('tsconfig-paths');
tsconfigPaths.register({
  baseUrl: '.',
  paths: { '@angular-redux/store': [''] },
});

const { getTestBed } = require('@angular/core/testing');
const {
  ServerTestingModule,
  platformServerTesting,
} = require('@angular/platform-server/testing');

getTestBed().initTestEnvironment(ServerTestingModule, platformServerTesting());

runner.loadConfig({
  spec_dir: '.',
  spec_files: ['**/*.spec.ts'],
});

runner.execute();
github angular / flex-layout / test / angular-test-init-node-spec.ts View on Github external
};
// 5) Patch jasmine ENV with code which understands ProxyZone.
import 'zone.js/dist/jasmine-patch.js';
// 6) Save the patched `jasmineCore` into global so that
// `@build_bazel_rules_nodejs//internal/jasmine_node_test/jasmine_runner.js` can get a hold of it
(global as any)['jasmineCore'] = jasmineCore;

(global as any).isNode = true;
(global as any).isBrowser = false;

// Init TestBed
import {TestBed} from '@angular/core/testing';
import {ServerTestingModule, platformServerTesting} from '@angular/platform-server/testing';
import {patchTestBedToDestroyFixturesAfterEveryTest} from './patch-testbed';

const testBed = TestBed.initTestEnvironment(ServerTestingModule, platformServerTesting());
patchTestBedToDestroyFixturesAfterEveryTest(testBed);
github angular / angularfire / tools / jasmine.js View on Github external
});

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

const { getTestBed } = require('@angular/core/testing');
const { platformServerTesting, ServerTestingModule } = require('@angular/platform-server/testing');

// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
    ServerTestingModule,
    platformServerTesting()
);

jasmine.execute();
github ngrx / platform / tools / testing / bootstrap_node_tests.ts View on Github external
import { TestBed } from '@angular/core/testing';
import {
  ServerTestingModule,
  platformServerTesting,
} from '@angular/platform-server/testing';

const originalConfigureTestingModule = TestBed.configureTestingModule;

TestBed.configureTestingModule = function() {
  TestBed.resetTestingModule();

  return originalConfigureTestingModule.apply(null, arguments as any);
};

TestBed.initTestEnvironment(ServerTestingModule, platformServerTesting());
github sharpangles / platform / libraries / platform-angular / src / features / angular_testing_server_feature.ts View on Github external
protected async bootstrap(rootModule: any) {
        getTestBed().initTestEnvironment(rootModule, platformServerTesting());
    }
}
github apollographql / apollo-angular / tests / integration.spec.ts View on Github external
obs.updateQuery((prev) => {
              const allHeroes = [...prev.allHeroes, result.addedHero];

              return { ...prev, allHeroes: allHeroes };
            });
          });
        }

        private pushNewHero() {
          client['networkInterface'].fireResult(1);
        }
      }

      getTestBed().initTestEnvironment(
        ServerTestingModule,
        platformServerTesting(),
      );

      getTestBed().configureTestingModule({
        declarations: [ HeroesComponent ],
        providers: [
          { provide: ComponentFixtureAutoDetect, useValue: true },
          APOLLO_PROVIDERS,
          provideClientMap(() => client),
        ],
      });

      const fixture = TestBed.createComponent(HeroesComponent);

      function getHTML(): string {
        return clearHTML(ɵgetDOM().getInnerHTML(fixture.nativeElement).trim());
      }
github angular / flex-layout / tools / gulp / tasks / unit-test-ssr.ts View on Github external
register({baseUrl, paths});
  require('zone.js/dist/zone-node.js');
  require('zone.js/dist/long-stack-trace-zone.js');
  require('zone.js/dist/proxy.js');
  require('zone.js/dist/sync-test.js');
  require('zone.js/dist/async-test.js');
  require('zone.js/dist/fake-async-test.js');
  require('zone.js/dist/task-tracking.js');
  require('reflect-metadata/Reflect');
  const jasmine = new (require('jasmine'))({projectBaseDir: projectDir});
  require('zone.js/dist/jasmine-patch.js');
  const {TestBed} = require('@angular/core/testing');
  const {ServerTestingModule, platformServerTesting} = require('@angular/platform-server/testing');
  let testBed = TestBed.initTestEnvironment(
    ServerTestingModule,
    platformServerTesting()
  );

  patchTestBed(testBed);
  jasmine.loadConfigFile('test/jasmine-ssr.json');
  jasmine.execute();
  done();
});
github zerothstack / zeroth / src / server / bootstrap.spec.ts View on Github external
import 'reflect-metadata';
import {platformServerTesting, ServerTestingModule} from '@angular/platform-server/testing';
import { TestBed } from '@angular/core/testing';

TestBed.initTestEnvironment(ServerTestingModule, platformServerTesting());
console.log('initialised test env');