當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Architect.scheduleTarget方法代碼示例

本文整理匯總了TypeScript中@angular-devkit/architect.Architect.scheduleTarget方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Architect.scheduleTarget方法的具體用法?TypeScript Architect.scheduleTarget怎麽用?TypeScript Architect.scheduleTarget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@angular-devkit/architect.Architect的用法示例。


在下文中一共展示了Architect.scheduleTarget方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it('uses deploy url for bundles urls and runtime', async () => {
    const overrides = { deployUrl: 'deployUrl/' };
    const overrides2 = { deployUrl: 'http://example.com/some/path/' };

    const run = await architect.scheduleTarget(targetSpec, overrides);
    const output = await run.result as BrowserBuilderOutput;
    expect(output.success).toBe(true);
    expect(output.outputPath).not.toBeUndefined();
    const outputPath = normalize(output.outputPath);

    const fileName = join(outputPath, 'index.html');
    const runtimeFileName = join(outputPath, 'runtime.js');
    const content = virtualFs.fileBufferToString(await host.read(normalize(fileName)).toPromise());
    expect(content).toContain('deployUrl/main.js');
    const runtimeContent = virtualFs.fileBufferToString(
      await host.read(normalize(runtimeFileName)).toPromise(),
    );
    expect(runtimeContent).toContain('deployUrl/');

    const run2 = await architect.scheduleTarget(targetSpec, overrides2);
    const output2 = await run2.result as BrowserBuilderOutput;
    expect(output2.outputPath).toEqual(outputPath);  // These should be the same.

    const content2 = virtualFs.fileBufferToString(await host.read(normalize(fileName)).toPromise());
    expect(content2).toContain('http://example.com/some/path/main.js');

    await run.stop();
    await run2.stop();
  });
開發者ID:angular,項目名稱:angular-cli,代碼行數:29,代碼來源:deploy-url_spec_large.ts

示例2: it

  it('executes tests with automatic dev server usage', async () => {
    const run = await architect.scheduleTarget(protractorTargetSpec);

    await expectAsync(run.result).toBeResolvedTo(jasmine.objectContaining({ success: true }));

    await run.stop();
  }, 30000);
開發者ID:angular,項目名稱:angular-cli,代碼行數:7,代碼來源:works_spec_large.ts

示例3: it

  it('works', async () => {
    // Create an express app that serves as a proxy.
    const app = express();
    const server = http.createServer(app);
    server.listen(0);

    app.set('port', (server.address() as AddressInfo).port);
    app.get('/api/test', function (_req, res) {
      res.send('TEST_API_RETURN');
    });

    const backendHost = 'localhost';
    // cast is safe, the HTTP server is not using a pipe or UNIX domain socket
    const backendPort = (server.address() as AddressInfo).port;
    const proxyServerUrl = `http://${backendHost}:${backendPort}`;

    host.writeMultipleFiles({
      'proxy.config.json': `{ "/api/*": { "target": "${proxyServerUrl}" } }`,
    });

    const run = await architect.scheduleTarget(target, { proxyConfig: 'proxy.config.json' });
    runs.push(run);
    const output = await run.result as DevServerBuilderOutput;
    expect(output.success).toBe(true);
    expect(output.baseUrl).toBe('http://localhost:4200/');

    const response = await fetch('http://localhost:4200/api/test');
    expect(await response.text()).toContain('TEST_API_RETURN');
    server.close();
  }, 30000);
開發者ID:angular,項目名稱:angular-cli,代碼行數:30,代碼來源:proxy_spec_large.ts

示例4: it

  it('works with aot', async () => {
    host.writeMultipleFiles({
      'src/my-js-file.js': `console.log(1); export const a = 2;`,
      'src/main.ts': `import { a } from './my-js-file'; console.log(a);`,
    });

    host.replaceInFile(
      'tsconfig.json',
      '"target": "es2015"',
      '"target": "es5", "allowJs": true',
    );

    const overrides = { aot: true };

    const run = await architect.scheduleTarget(targetSpec, overrides);
    const output = await run.result as BrowserBuilderOutput;
    expect(output.success).toBe(true);

    const content = virtualFs.fileBufferToString(
      await host.read(join(normalize(output.outputPath), 'main.js')).toPromise(),
    );

    expect(content).toContain('var a = 2');

    await run.stop();
  });
開發者ID:angular,項目名稱:angular-cli,代碼行數:26,代碼來源:allow-js_spec_large.ts

示例5: it

  it('performs initial build', async () => {
    const run = await architect.scheduleTarget(karmaTargetSpec, { watch: true });

    await expectAsync(run.result).toBeResolvedTo(jasmine.objectContaining({ success: true }));

    await run.stop();
  });
開發者ID:angular,項目名稱:angular-cli,代碼行數:7,代碼來源:rebuilds_spec_large.ts

示例6: it

  it('works', async () => {
    const overrides = { watch: true, poll: 10000 };
    const intervals: number[] = [];
    let startTime: number | undefined;

    const run = await architect.scheduleTarget(target, overrides);
    await run.output.pipe(
      // Debounce 1s, otherwise changes are too close together and polling doesn't work.
      debounceTime(1000),
      tap((buildEvent) => {
        expect(buildEvent.success).toBe(true);
        if (startTime != undefined) {
          intervals.push(Date.now() - startTime - 1000);
        }
        startTime = Date.now();
        host.appendToFile('src/main.ts', 'console.log(1);');
      }),
      take(4),
    ).toPromise();

    intervals.sort();
    const median = intervals[Math.trunc(intervals.length / 2)];
    expect(median).toBeGreaterThan(3000);
    expect(median).toBeLessThan(12000);
  });
開發者ID:angular,項目名稱:angular-cli,代碼行數:25,代碼來源:poll_spec_large.ts

示例7: it

  it('type checks on rebuilds', async () => {
    host.writeMultipleFiles({
      'src/funky2.ts': `export const funky2 = (value: string) => value + 'hello';`,
      'src/funky.ts': `export * from './funky2';`,
    });
    host.appendToFile('src/main.ts', `
      import { funky2 } from './funky';
      console.log(funky2('town'));
    `);

    const overrides = { watch: true, forkTypeChecker: false };
    const logger = new TestLogger('rebuild-type-errors');
    const typeError = `is not assignable to parameter of type 'number'`;
    let buildNumber = 0;

    const run = await architect.scheduleTarget(target, overrides, { logger });
    await run.output.pipe(
      debounceTime(1000),
      tap((buildEvent) => {
        buildNumber += 1;
        switch (buildNumber) {
          case 1:
            expect(buildEvent.success).toBe(true);
            // Make an invalid version of the file.
            // Should trigger a rebuild, this time an error is expected.
            host.writeMultipleFiles({
              'src/funky2.ts': `export const funky2 = (value: number) => value + 1;`,
            });
            break;

          case 2:
            // The second build should error out with a type error on the type of an argument.
            expect(buildEvent.success).toBe(false);
            expect(logger.includes(typeError)).toBe(true);
            logger.clear();
            // Change an UNRELATED file and the error should still happen.
            // Should trigger a rebuild, this time an error is also expected.
            host.appendToFile('src/app/app.module.ts', `console.log(1);`);
            break;

          case 3:
            // The third build should have the same error as the first.
            expect(buildEvent.success).toBe(false);
            expect(logger.includes(typeError)).toBe(true);
            logger.clear();
            // Fix the error.
            host.writeMultipleFiles({
              'src/funky2.ts': `export const funky2 = (value: string) => value + 'hello';`,
            });
            break;

          default:
            expect(buildEvent.success).toBe(true);
            break;
        }
      }),
      take(4),
    ).toPromise();
    await run.stop();
  });
開發者ID:angular,項目名稱:angular-cli,代碼行數:60,代碼來源:rebuild_spec_large.ts


注:本文中的@angular-devkit/architect.Architect.scheduleTarget方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。