Home / File/ test-packaging-fixture.js — react Source File

test-packaging-fixture.js — react Source File

Architecture documentation for test-packaging-fixture.js, a javascript file in the react codebase.

Entity Profile

Relationship Graph

Source Code

#!/usr/bin/env node

'use strict';

const {exec} = require('child-process-promise');
const {join} = require('path');
const puppeteer = require('puppeteer');
const server = require('pushstate-server');
const theme = require('../theme');
const {logPromise} = require('../utils');

const validate = async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();

  await page.goto('http://localhost:9000/fixtures/packaging');

  try {
    return await page.evaluate(() => {
      const iframes = document.querySelectorAll('iframe');

      if (iframes.length === 0) {
        return 'No iframes were found.';
      }

      for (let i = 0; i < iframes.length; i++) {
        const iframe = iframes[i];
        // Don't include the <script> Babel tag
        const container =
          iframe.contentDocument.body.getElementsByTagName('div')[0];
        if (container.textContent !== 'Hello World!') {
          return `Unexpected fixture content, "${container.textContent}"`;
        }
      }

      return null;
    });
  } finally {
    await browser.close();
  }
};

const run = async ({cwd}) => {
  await logPromise(
    exec('node build-all.js', {cwd: join(cwd, 'fixtures/packaging')}),
    'Generating "packaging" fixture',
    20000 // This takes roughly 20 seconds
  );

  let errorMessage;
  let response;

  try {
    response = server.start({
      port: 9000,
      directory: cwd,
    });

    errorMessage = await logPromise(
      validate(),
      'Verifying "packaging" fixture'
    );
  } finally {
    response.close();
  }

  if (errorMessage) {
    console.error(
      theme.error('✗'),
      'Verifying "packaging" fixture\n ',
      theme.error(errorMessage)
    );
    process.exit(1);
  }
};

module.exports = run;

Domain

Subdomains

Functions

Frequently Asked Questions

What does test-packaging-fixture.js do?
test-packaging-fixture.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in test-packaging-fixture.js?
test-packaging-fixture.js defines 2 function(s): run, validate.
Where is test-packaging-fixture.js in the architecture?
test-packaging-fixture.js is located at scripts/release/shared-commands/test-packaging-fixture.js (domain: BabelCompiler, subdomain: Optimization, directory: scripts/release/shared-commands).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free