scripts/test.e2e.js
/**
 * When running e2e tests with cypress we need to first get the server up and running
 * before launching the test suite. Additionally we will pass a random DB_PREFIX variable
 * to both the tests and platform which will provide a unique set seed data on the db
 * to work with (and avoid parallel tests accidentally overwriting each other).
 *
 * @argument ci - specify if running in ci (e.g. travis) to run and record
 * @example npm run test:e2e ci
 */
When running e2e tests with cypress we need to first get the server up and running
before launching the test suite. Additionally we will pass a random DB_PREFIX variable
to both the tests and platform which will provide a unique set seed data on the db
to work with (and avoid parallel tests accidentally overwriting each other).

@argument ci - specify if running in ci  to run and record
@example npm run test:e2e ci
When running e2e tests with cypress we need to first get the server up and running before launching the test suite . Additionally we will pass a random DB_PREFIX variable to both the tests and platform which will provide a unique set seed data on the db to work with ( and avoid parallel tests accidentally overwriting each other ) . @argument ci - specify if running in ci to run and record @example npm run test : e2e ci
async function main() {
  const isCi = process.argv[2] === 'ci'
  const DB_PREFIX = `${randomString(5)}_`
  const sharedEnv = `REACT_APP_DB_PREFIX=${DB_PREFIX} REACT_APP_SITE_VARIANT=test-ci`
  const cyEnv = getCypressEnv(sharedEnv)
  const appStart = `cross-env ${sharedEnv} BROWSER=none PORT=3456 npm run start`
  const waitForStart = 'http-get://localhost:3456'
  const testStart = isCi
    ? 
      `npx cypress run --record --env ${cyEnv.runtime} --key=${cyEnv.CYPRESS_KEY} --parallel --headless --browser $CI_BROWSER --group $CI_GROUP --ci-build-id $TRAVIS_BUILD_ID`
    : `npx cypress open --browser chrome --env ${cyEnv.runtime}`
  const spawn = child.spawnSync(
    `npx start-test "${appStart}" "${waitForStart}" "${testStart}"`,
    {
      shell: true,
      stdio: ['inherit', 'inherit', 'inherit'],
    },
  )
  if (spawn.status === 1) {
    process.exitCode = 1
  }
}
async function main ( ) { const isCi = process . argv [ 2 ] === 'ci' const DB_PREFIX = ` ${ randomString ( 5 ) } ` const sharedEnv = ` ${ DB_PREFIX } ` const cyEnv = getCypressEnv ( sharedEnv ) const appStart = ` ${ sharedEnv } ` const waitForStart = 'http-get://localhost:3456' const testStart = isCi ? ` ${ cyEnv . runtime } ${ cyEnv . CYPRESS_KEY } ` : ` ${ cyEnv . runtime } ` const spawn = child . spawnSync ( ` ${ appStart } ${ waitForStart } ${ testStart } ` , { shell : true , stdio : [ 'inherit' , 'inherit' , 'inherit' ] , } , ) if ( spawn . status === 1 ) { process . exitCode = 1 } }
When running e2e tests with cypress we need to first get the server up and running
 before launching the test suite.
When running e2e tests with cypress we need to first get the server up and running before launching the test suite .
//   TODO - cypress specific environment to be moved to other environment // errors inherited by stdio above don't cause exit, so handle now