How to use @angular/platform-server - 10 common examples

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 / preboot / test / unit / server / server-preboot.module.spec.js View on Github external
var AppModule = (function () {
                function AppModule() {
                }
                AppModule = __decorate([
                    core_1.NgModule({
                        declarations: [AppComponent],
                        imports: [
                            platform_browser_1.BrowserModule.withServerTransition({ appId: 'my-app-id' }),
                            platform_server_1.ServerModule,
                            src_1.ServerPrebootModule.recordEvents({ appRoot: 'app-root' })
                        ],
                        bootstrap: [AppComponent]
                    })
                ], AppModule);
                return AppModule;
            }());
            // get the JIT compiler (not exposed publically, so need to inject it)
github angular / angular / tools / testing / init_node_spec.ts View on Github external
// global.jasmine so that it can be patched by zone.js jasmine-patch.js.
require('@bazel/jasmine').boot();
import 'zone.js/lib/jasmine/jasmine';

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

import '@angular/compiler'; // For JIT mode. Must be in front of any other @angular/* imports.
// Init TestBed
import {TestBed} from '@angular/core/testing';
import {ServerTestingModule, platformServerTesting} from '@angular/platform-server/testing/src/server';
import {DominoAdapter} from '@angular/platform-server/src/domino_adapter';
import {createDocument} from 'domino';

TestBed.initTestEnvironment(ServerTestingModule, platformServerTesting());
DominoAdapter.makeCurrent();
(global as any).document =
    (DominoAdapter as any).defaultDoc || ((DominoAdapter as any).defaultDoc = createDocument());
github angular / angular / tools / testing / init_node_spec.ts View on Github external
const jasmineCore: any = require('jasmine-core');
jasmineCore.boot(jasmineCore);
import 'zone.js/dist/jasmine-patch.js';

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

import '@angular/compiler'; // For JIT mode. Must be in front of any other @angular/* imports.
// Init TestBed
import {TestBed} from '@angular/core/testing';
import {ServerTestingModule, platformServerTesting} from '@angular/platform-server/testing/src/server';
import {DominoAdapter} from '@angular/platform-server/src/domino_adapter';
import {createDocument} from 'domino';

TestBed.initTestEnvironment(ServerTestingModule, platformServerTesting());
DominoAdapter.makeCurrent();
(global as any).document =
    (DominoAdapter as any).defaultDoc || ((DominoAdapter as any).defaultDoc = createDocument());
github angular / angular / tools / testing / init_node_spec.ts View on Github external
// Initialize jasmine with @bazel/jasmine boot() function. This will initialize
// global.jasmine so that it can be patched by zone.js jasmine-patch.js.
require('@bazel/jasmine').boot();
import 'zone.js/lib/jasmine/jasmine';

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

import '@angular/compiler'; // For JIT mode. Must be in front of any other @angular/* imports.
// Init TestBed
import {TestBed} from '@angular/core/testing';
import {ServerTestingModule, platformServerTesting} from '@angular/platform-server/testing/src/server';
import {DominoAdapter} from '@angular/platform-server/src/domino_adapter';
import {createDocument} from 'domino';

TestBed.initTestEnvironment(ServerTestingModule, platformServerTesting());
DominoAdapter.makeCurrent();
(global as any).document =
    (DominoAdapter as any).defaultDoc || ((DominoAdapter as any).defaultDoc = createDocument());
github angular / angular / tools / testing / init_node_spec.ts View on Github external
// See https://github.com/bazelbuild/rules_nodejs/pull/539
const jasmineCore: any = require('jasmine-core');
jasmineCore.boot(jasmineCore);
import 'zone.js/dist/jasmine-patch.js';

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

import '@angular/compiler'; // For JIT mode. Must be in front of any other @angular/* imports.
// Init TestBed
import {TestBed} from '@angular/core/testing';
import {ServerTestingModule, platformServerTesting} from '@angular/platform-server/testing/src/server';
import {DominoAdapter} from '@angular/platform-server/src/domino_adapter';
import {createDocument} from 'domino';

TestBed.initTestEnvironment(ServerTestingModule, platformServerTesting());
DominoAdapter.makeCurrent();
(global as any).document =
    (DominoAdapter as any).defaultDoc || ((DominoAdapter as any).defaultDoc = createDocument());
github AngularClass / universal-sitegen / src / server.ts View on Github external
export function site (
  serverModuleFactory: Type<{}>,
  document: string,
  url: string = '/',
  config?: string | SiteGenConfig
) {
  // if (typeof config === 'string') {
  //   config = require.resolve(path.join(process.cwd(), config))
  // }

  // console.log('config here ', config)
  return renderModule(
    serverModuleFactory,
    {document, url}
  )
}
github Innovic-io / angular-nestjs-rendering / src / server / main.ts View on Github external
expressApp.engine('html', (_, options, callback) => {
    renderModuleFactory(AppServerModuleNgFactory, {
      // Our index.html
      document: template,
      url: options.req.url,
      // DI so that we can get lazy-loading to work differently (since we need it to just instantly render it)
      extraProviders: [
        provideModuleMap(LAZY_MODULE_MAP),
        {
          provide: 'serverUrl',
          useValue: `${options.req.protocol}://${options.req.get('host')}`
        }
      ]
    }).then(html => {
      callback(null, html);
    });
  });