How to use the jest.run function in jest

To help you get started, we’ve selected a few jest 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 kulshekhar / ts-jest / scripts / tests.js View on Github external
);

    // Copy dist folder
    fs.copySync(
      path.resolve(rootDir, 'dist'),
      path.resolve(testCaseModuleFolder, 'dist')
    );
  });
}

createIntegrationMock();

const argv = process.argv.slice(2);
argv.push('--no-cache');
argv.push('--config', path.join(Paths.rootDir, 'jest.config.tests.js'));
jest.run(argv);
github walrusjs / walrus / packages / walrus-plugin-jest / src / index.ts View on Github external
(args, rawArgv) => {
      const rootDir = api.resolve('.');
      // 获取默认配置
      const defaultConfig = new DefaultConfigResolver(rootDir);

      const configuration = new JestConfigurationBuilder(
        defaultConfig,
        new CustomConfigResolver()
      ).buildConfiguration(process.cwd());
      rawArgv.push('--config', JSON.stringify(configuration));
      // 未查找到测试文件正常退出
      rawArgv.push('--passWithNoTests');
      run(rawArgv)
        .then((result) => {
          debug(result);
        })
        .catch((e) => {
          console.log(e);
        });
    }
  );
github philopian / AppSeed / .jest / index.js View on Github external
const appDirectory = fs.realpathSync(process.cwd());

// Run Jest on the application files (./www/* & ./server/*)
const jest = require("jest");
let jestConfig = require("./config");
jestConfig.roots = [appDirectory];
delete jestConfig.collectCoverageFrom;
delete jestConfig.coverageDirectory;
delete jestConfig.reporters;
const jestCommand = [
  "--env=jsdom",
  "--watchAll",
  "--config",
  JSON.stringify(jestConfig)
];
jest.run(jestCommand);
github WordPress / gutenberg / bin / setup-packages-e2e-tests.js View on Github external
bundler.on( 'buildEnd', () => {
	jest.run( [
		'--config',
		'bin/jest.config.js',
		'--rootDir',
		resolve( __dirname, '..' ),
		'--runInBand',
		...process.argv.slice( 2 ),
	] ).then( () => {
		process.exit( 0 );
	} ).catch( () => {
		process.exit( 1 );
	} );
} );
github elastic / kibana / src / dev / jest / cli.js View on Github external
* not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import jest from 'jest';

jest.run(process.argv.slice(2));
github carbon-design-system / toolkit / packages / cli-plugin-jest / index.js View on Github external
if (Array.isArray(object) && Array.isArray(src)) {
          return [...object, ...src];
        }

        if (typeof object === 'object' && typeof src === 'object') {
          return {
            ...object,
            ...src,
          };
        }
      });
      const args = process.argv.slice(3);
      const cliArgs = args.concat('--config', JSON.stringify(config));

      if (args.includes('--help')) {
        return jest.run(args);
      }

      return jest.run(cliArgs);
    },
  });
github just-jeb / angular-builders / packages / jest / src / index.ts View on Github external
async function runJestCLI() {
    const argv = await buildArgv();
    //TODO: use runCLI to better determine the outcome
    return run(argv);
  }
github msn0 / vrt-react / index.js View on Github external
server.listen(port, 'localhost', async () => {
        await jest.run([
            '--silent',
            cli.flags.fail ? '' : '--updateSnapshot',
            '--detectOpenHandles',
            '--runTestsByPath'
        ].filter(Boolean).concat(testFiles));

        if (!cli.flags.watch) {
            server.close();
            fs.removeSync(vrtDir);
        }
    });
github just-jeb / angular-builders / packages / jest / src / jest.builder.ts View on Github external
run(builderConfig: BuilderConfiguration>): Observable {
    const {options, root, sourceRoot} = builderConfig;
    const workspaceRoot = this.context.workspace.root;

    const configuration = this.jestConfigurationBuilder.buildConfiguration(root, sourceRoot, workspaceRoot, options.configPath);
    delete options.configPath;
    const argv = this.optionsConverter.convertToCliArgs(options);

    argv.push('--config', JSON.stringify(configuration));
    return from(jest.run(argv)).pipe(map(() => ({success: true})));
  }