test.js 994 B

1234567891011121314151617181920212223242526272829303132
  1. process.env.NODE_ENV = 'test';
  2. process.env.PUBLIC_URL = '';
  3. // Load environment variables from .env file. Suppress warnings using silent
  4. // if this file is missing. dotenv will never modify any environment variables
  5. // that have already been set.
  6. // https://github.com/motdotla/dotenv
  7. require('dotenv').config({silent: true});
  8. const jest = require('jest');
  9. const argv = process.argv.slice(2);
  10. // Watch unless on CI or in coverage mode
  11. if (!process.env.CI && argv.indexOf('--coverage') < 0) {
  12. argv.push('--watch');
  13. }
  14. // A temporary hack to clear terminal correctly.
  15. // You can remove this after updating to Jest 18 when it's out.
  16. // https://github.com/facebook/jest/pull/2230
  17. var realWrite = process.stdout.write;
  18. var CLEAR = process.platform === 'win32' ? '\x1Bc' : '\x1B[2J\x1B[3J\x1B[H';
  19. process.stdout.write = function(chunk, encoding, callback) {
  20. if (chunk === '\x1B[2J\x1B[H') {
  21. chunk = CLEAR;
  22. }
  23. return realWrite.call(this, chunk, encoding, callback);
  24. };
  25. jest.run(argv);