Best JavaScript code snippet using fast-check-monorepo
run_jest.js
Source:run_jest.js
1'use strict';2Object.defineProperty(exports, '__esModule', {3 value: true4});5var _micromatch;6function _load_micromatch() {7 return (_micromatch = _interopRequireDefault(require('micromatch')));8}9var _chalk;10function _load_chalk() {11 return (_chalk = _interopRequireDefault(require('chalk')));12}13var _path;14function _load_path() {15 return (_path = _interopRequireDefault(require('path')));16}17var _jestUtil;18function _load_jestUtil() {19 return (_jestUtil = require('jest-util'));20}21var _exit;22function _load_exit() {23 return (_exit = _interopRequireDefault(require('exit')));24}25var _gracefulFs;26function _load_gracefulFs() {27 return (_gracefulFs = _interopRequireDefault(require('graceful-fs')));28}29var _get_no_test_found_message;30function _load_get_no_test_found_message() {31 return (_get_no_test_found_message = _interopRequireDefault(32 require('./get_no_test_found_message')33 ));34}35var _search_source;36function _load_search_source() {37 return (_search_source = _interopRequireDefault(require('./search_source')));38}39var _test_scheduler;40function _load_test_scheduler() {41 return (_test_scheduler = _interopRequireDefault(42 require('./test_scheduler')43 ));44}45var _test_sequencer;46function _load_test_sequencer() {47 return (_test_sequencer = _interopRequireDefault(48 require('./test_sequencer')49 ));50}51var _test_result_helpers;52function _load_test_result_helpers() {53 return (_test_result_helpers = require('./test_result_helpers'));54}55var _failed_tests_cache;56function _load_failed_tests_cache() {57 return (_failed_tests_cache = _interopRequireDefault(58 require('./failed_tests_cache')59 ));60}61var _jestWatcher;62function _load_jestWatcher() {63 return (_jestWatcher = require('jest-watcher'));64}65var _get_node_handles;66function _load_get_node_handles() {67 return (_get_node_handles = _interopRequireDefault(68 require('./get_node_handles')69 ));70}71function _interopRequireDefault(obj) {72 return obj && obj.__esModule ? obj : {default: obj};73}74function _asyncToGenerator(fn) {75 return function() {76 var gen = fn.apply(this, arguments);77 return new Promise(function(resolve, reject) {78 function step(key, arg) {79 try {80 var info = gen[key](arg);81 var value = info.value;82 } catch (error) {83 reject(error);84 return;85 }86 if (info.done) {87 resolve(value);88 } else {89 return Promise.resolve(value).then(90 function(value) {91 step('next', value);92 },93 function(err) {94 step('throw', err);95 }96 );97 }98 }99 return step('next');100 });101 };102} /**103 * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.104 *105 * This source code is licensed under the MIT license found in the106 * LICENSE file in the root directory of this source tree.107 *108 *109 */110const setConfig = (contexts, newConfig) =>111 contexts.forEach(112 context =>113 (context.config = Object.freeze(114 Object.assign({}, context.config, newConfig)115 ))116 );117const getTestPaths = (() => {118 var _ref = _asyncToGenerator(function*(119 globalConfig,120 context,121 outputStream,122 changedFilesPromise,123 jestHooks124 ) {125 const source = new (_search_source || _load_search_source()).default(126 context127 );128 const data = yield source.getTestPaths(globalConfig, changedFilesPromise);129 if (!data.tests.length && globalConfig.onlyChanged && data.noSCM) {130 new (_jestUtil || _load_jestUtil()).Console(131 outputStream,132 outputStream133 ).log(134 'Jest can only find uncommitted changed files in a git or hg ' +135 'repository. If you make your project a git or hg ' +136 'repository (`git init` or `hg init`), Jest will be able ' +137 'to only run tests related to files changed since the last ' +138 'commit.'139 );140 }141 const shouldTestArray = yield Promise.all(142 data.tests.map(function(test) {143 return jestHooks.shouldRunTestSuite({144 config: test.context.config,145 duration: test.duration,146 testPath: test.path147 });148 })149 );150 const filteredTests = data.tests.filter(function(test, i) {151 return shouldTestArray[i];152 });153 return Object.assign({}, data, {154 allTests: filteredTests.length,155 tests: filteredTests156 });157 });158 return function getTestPaths(_x, _x2, _x3, _x4, _x5) {159 return _ref.apply(this, arguments);160 };161})();162const processResults = (runResults, options) => {163 const outputFile = options.outputFile,164 isJSON = options.isJSON,165 onComplete = options.onComplete,166 outputStream = options.outputStream,167 testResultsProcessor = options.testResultsProcessor,168 collectHandles = options.collectHandles;169 if (collectHandles) {170 runResults.openHandles = collectHandles();171 } else {172 runResults.openHandles = [];173 }174 if (testResultsProcessor) {175 /* $FlowFixMe */176 runResults = require(testResultsProcessor)(runResults);177 }178 if (isJSON) {179 if (outputFile) {180 const filePath = (_path || _load_path()).default.resolve(181 process.cwd(),182 outputFile183 );184 (_gracefulFs || _load_gracefulFs()).default.writeFileSync(185 filePath,186 JSON.stringify(187 (0, (_jestUtil || _load_jestUtil()).formatTestResults)(runResults)188 )189 );190 outputStream.write(191 `Test results written to: ` +192 `${(_path || _load_path()).default.relative(193 process.cwd(),194 filePath195 )}\n`196 );197 } else {198 process.stdout.write(199 JSON.stringify(200 (0, (_jestUtil || _load_jestUtil()).formatTestResults)(runResults)201 )202 );203 }204 }205 return onComplete && onComplete(runResults);206};207const testSchedulerContext = {208 firstRun: true,209 previousSuccess: true210};211exports.default = (() => {212 var _ref3 = _asyncToGenerator(function*(_ref2) {213 let contexts = _ref2.contexts,214 globalConfig = _ref2.globalConfig,215 outputStream = _ref2.outputStream,216 testWatcher = _ref2.testWatcher;217 var _ref2$jestHooks = _ref2.jestHooks;218 let jestHooks =219 _ref2$jestHooks === undefined220 ? new (_jestWatcher || _load_jestWatcher()).JestHook().getEmitter()221 : _ref2$jestHooks,222 startRun = _ref2.startRun,223 changedFilesPromise = _ref2.changedFilesPromise,224 onComplete = _ref2.onComplete,225 failedTestsCache = _ref2.failedTestsCache;226 const sequencer = new (_test_sequencer || _load_test_sequencer()).default();227 let allTests = [];228 if (changedFilesPromise && globalConfig.watch) {229 var _ref4 = yield changedFilesPromise;230 const repos = _ref4.repos;231 const noSCM = Object.keys(repos).every(function(scm) {232 return repos[scm].size === 0;233 });234 if (noSCM) {235 process.stderr.write(236 '\n' +237 (_chalk || _load_chalk()).default.bold('--watch') +238 ' is not supported without git/hg, please use --watchAll ' +239 '\n'240 );241 (0, (_exit || _load_exit()).default)(1);242 }243 }244 let collectCoverageFrom = [];245 const testRunData = yield Promise.all(246 contexts.map(247 (() => {248 var _ref5 = _asyncToGenerator(function*(context) {249 const matches = yield getTestPaths(250 globalConfig,251 context,252 outputStream,253 changedFilesPromise,254 jestHooks255 );256 allTests = allTests.concat(matches.tests);257 if (matches.collectCoverageFrom) {258 collectCoverageFrom = collectCoverageFrom.concat(259 matches.collectCoverageFrom.filter(function(filename) {260 if (261 globalConfig.collectCoverageFrom &&262 !(0, (_micromatch || _load_micromatch()).default)(263 [264 (_path || _load_path()).default.relative(265 globalConfig.rootDir,266 filename267 )268 ],269 globalConfig.collectCoverageFrom270 ).length271 ) {272 return false;273 }274 if (275 globalConfig.coveragePathIgnorePatterns &&276 globalConfig.coveragePathIgnorePatterns.some(function(277 pattern278 ) {279 return filename.match(pattern);280 })281 ) {282 return false;283 }284 return true;285 })286 );287 }288 return {context, matches};289 });290 return function(_x7) {291 return _ref5.apply(this, arguments);292 };293 })()294 )295 );296 if (collectCoverageFrom.length) {297 globalConfig = Object.freeze(298 Object.assign({}, globalConfig, {collectCoverageFrom})299 );300 }301 allTests = sequencer.sort(allTests);302 if (globalConfig.listTests) {303 const testsPaths = Array.from(304 new Set(305 allTests.map(function(test) {306 return test.path;307 })308 )309 );310 if (globalConfig.json) {311 console.log(JSON.stringify(testsPaths));312 } else {313 console.log(testsPaths.join('\n'));314 }315 onComplete &&316 onComplete(317 (0,318 (_test_result_helpers || _load_test_result_helpers())319 .makeEmptyAggregatedTestResult)()320 );321 return null;322 }323 if (globalConfig.onlyFailures && failedTestsCache) {324 allTests = failedTestsCache.filterTests(allTests);325 globalConfig = failedTestsCache.updateConfig(globalConfig);326 }327 if (!allTests.length) {328 const noTestsFoundMessage = (0,329 (_get_no_test_found_message || _load_get_no_test_found_message())330 .default)(testRunData, globalConfig);331 if (332 globalConfig.passWithNoTests ||333 globalConfig.findRelatedTests ||334 globalConfig.lastCommit ||335 globalConfig.onlyChanged336 ) {337 new (_jestUtil || _load_jestUtil()).Console(338 outputStream,339 outputStream340 ).log(noTestsFoundMessage);341 } else {342 new (_jestUtil || _load_jestUtil()).Console(343 outputStream,344 outputStream345 ).error(noTestsFoundMessage);346 (0, (_exit || _load_exit()).default)(1);347 }348 } else if (349 allTests.length === 1 &&350 globalConfig.silent !== true &&351 globalConfig.verbose !== false352 ) {353 globalConfig = Object.freeze(354 Object.assign({}, globalConfig, {verbose: true})355 );356 }357 // When using more than one context, make all printed paths relative to the358 // current cwd. Do not modify rootDir, since will be used by custom resolvers.359 // If --runInBand is true, the resolver saved a copy during initialization,360 // however, if it is running on spawned processes, the initiation of the361 // custom resolvers is done within each spawned process and it needs the362 // original value of rootDir. Instead, use the {cwd: Path} property to resolve363 // paths when printing.364 setConfig(contexts, {cwd: process.cwd()});365 let collectHandles;366 if (globalConfig.detectOpenHandles) {367 collectHandles = (0,368 (_get_node_handles || _load_get_node_handles()).default)();369 }370 if (globalConfig.globalSetup) {371 // $FlowFixMe372 const globalSetup = require(globalConfig.globalSetup);373 if (typeof globalSetup !== 'function') {374 throw new TypeError(375 `globalSetup file must export a function at ${376 globalConfig.globalSetup377 }`378 );379 }380 yield globalSetup();381 }382 const results = yield new (383 _test_scheduler || _load_test_scheduler()384 ).default(385 globalConfig,386 {387 startRun388 },389 testSchedulerContext390 ).scheduleTests(allTests, testWatcher);391 sequencer.cacheResults(allTests, results);392 if (globalConfig.globalTeardown) {393 // $FlowFixMe394 const globalTeardown = require(globalConfig.globalTeardown);395 if (typeof globalTeardown !== 'function') {396 throw new TypeError(397 `globalTeardown file must export a function at ${398 globalConfig.globalTeardown399 }`400 );401 }402 yield globalTeardown();403 }404 return processResults(results, {405 collectHandles,406 isJSON: globalConfig.json,407 onComplete,408 outputFile: globalConfig.outputFile,409 outputStream,410 testResultsProcessor: globalConfig.testResultsProcessor411 });412 });413 function runJest(_x6) {414 return _ref3.apply(this, arguments);415 }416 return runJest;...
gruntfile.js
Source:gruntfile.js
1module.exports = function (grunt) {2 'use strict';3 grunt.loadNpmTasks('grunt-contrib-concat');4 grunt.loadNpmTasks('grunt-contrib-uglify');5 grunt.loadNpmTasks('grunt-contrib-cssmin');6 grunt.loadNpmTasks('grunt-contrib-sass');7 grunt.loadNpmTasks('grunt-contrib-watch');8 grunt.loadNpmTasks('grunt-autoprefixer');9 var configBridge = grunt.file.readJSON('./configBridge.json', { encoding: 'utf8' });10 // to do11 var globalConfig = {12 public_html: '/',13 assets: 'assets',14 source: 'source',15 stylesheet: 'styles',16 javascript: 'app',17 };18 // Project configuration.19 grunt.initConfig({20 // Config Variable21 globalConfig: globalConfig,22 sass: {23 dist: {24 files: {25 '<%= globalConfig.assets %>/css/<%= globalConfig.stylesheet %>.css': '<%= globalConfig.source %>/scss/<%= globalConfig.stylesheet %>.scss'26 }27 }28 },29 autoprefixer: {30 options: {31 browsers: configBridge.config.autoprefixerBrowsers32 },33 development: {34 options: {35 map: true36 },37 src: '<%= globalConfig.assets %>/css/*.css'38 },39 },40 cssmin: {41 options: {42 compatibility: 'ie11',43 keepSpecialComments: '*',44 sourceMap: false,45 advanced: false46 },47 cssvendor: {48 src: '<%= globalConfig.assets %>/css/vendor.css',49 dest: '<%= globalConfig.assets %>/css/vendor.min.css'50 },51 cssstyle: {52 src: '<%= globalConfig.assets %>/css/<%= globalConfig.stylesheet %>.css',53 dest: '<%= globalConfig.assets %>/css/<%= globalConfig.stylesheet %>.min.css'54 },55 },56 concat: {57 cssvendor: {58 src: [59 '<%= globalConfig.source %>/scss/vendor/*.css'60 ],61 dest: '<%= globalConfig.assets %>/css/vendor.css'62 },63 jsvendor: {64 src: [65 '<%= globalConfig.source %>/js/vendor/*.js'66 ],67 dest: '<%= globalConfig.assets %>/js/vendor.js'68 },69 app: {70 src: [71 '<%= globalConfig.source %>/js/<%= globalConfig.javascript %>.js'72 ],73 dest: '<%= globalConfig.assets %>/js/<%= globalConfig.javascript %>.js'74 }75 },76 uglify: {77 options: {78 compress: {79 warnings: false80 },81 mangle: true,82 preserveComments: false83 },84 vendor: {85 src: '<%= concat.jsvendor.dest %>',86 dest: '<%= globalConfig.assets %>/js/vendor.min.js'87 },88 app: {89 src: '<%= globalConfig.assets %>/js/<%= globalConfig.javascript %>.js',90 dest: '<%= globalConfig.assets %>/js/<%= globalConfig.javascript %>.min.js'91 },92 },93 watch: {94 css: {95 files: ['<%= globalConfig.source %>/scss/*.scss', '<%= globalConfig.source %>/scss/*/*.scss'],96 tasks: ['css']97 },98 javascript: {99 files: ['<%= globalConfig.source %>/js/vendor/*.js', '<%= globalConfig.source %>/js/<%= globalConfig.javascript %>.js'],100 tasks: ['js']101 },102 },103 });104 grunt.registerTask('js', ['concat', 'uglify']);105 grunt.registerTask('css', ['sass', 'concat', 'autoprefixer', 'cssmin']);106 //grunt.registerTask('default', ['js', 'css']);...
test_unit_ocsp_mode.js
Source:test_unit_ocsp_mode.js
1/*2 * Copyright (c) 2019 Snowflake Computing Inc. All rights reserved.3 */4const GlobalConfig = require('../../../lib/global_config');5const assert = require('assert');6describe('OCSP mode', function ()7{8 it('getOcspMode', function (done)9 {10 // insecure mode11 GlobalConfig.setInsecureConnect(true);12 assert.equal(GlobalConfig.getOcspMode(), GlobalConfig.ocspModes.INSECURE);13 // insecure mode + Fail open14 GlobalConfig.setOcspFailOpen(true);15 assert.equal(GlobalConfig.getOcspMode(), GlobalConfig.ocspModes.INSECURE);16 GlobalConfig.setInsecureConnect(false);17 assert.equal(GlobalConfig.getOcspMode(), GlobalConfig.ocspModes.FAIL_OPEN);18 GlobalConfig.setOcspFailOpen(false);19 assert.equal(GlobalConfig.getOcspMode(), GlobalConfig.ocspModes.FAIL_CLOSED);20 GlobalConfig.setOcspFailOpen(true);21 done();22 });...
Using AI Code Generation
1const { globalConfig } = require('fast-check-monorepo');2globalConfig({ seed: 42 });3const { globalConfig } = require('fast-check-monorepo');4globalConfig({ seed: 42 });5const { globalConfig } = require('fast-check-monorepo');6globalConfig({ seed: 42 });7const { globalConfig } = require('fast-check-monorepo');8globalConfig({ seed: 42 });9const { globalConfig } = require('fast-check-monorepo');10globalConfig({ seed: 42 });11const { globalConfig } = require('fast-check-monorepo');12globalConfig({ seed: 42 });13const { globalConfig } = require('fast-check-monorepo');14globalConfig({ seed: 42 });15const { globalConfig } = require('fast-check-monorepo');16globalConfig({ seed: 42 });17const { globalConfig } = require('fast-check-monorepo');18globalConfig({ seed: 42 });19const { globalConfig } = require('fast-check-monorepo');20globalConfig({ seed: 42 });21const { globalConfig } = require('fast-check-monorepo');22globalConfig({ seed: 42 });23const { globalConfig } = require('fast-check-monorepo');24globalConfig({ seed: 42 });
Using AI Code Generation
1const fc = require('fast-check');2const { globalConfig } = require('fast-check-monorepo');3const fc = require('fast-check');4const { globalConfig } = require('fast-check-monorepo');5const fc = require('fast-check');6const { globalConfig } = require('fast-check-monorepo');7const fc = require('fast-check');8const { globalConfig } = require('fast-check-monorepo');9const fc = require('fast-check');10const { globalConfig } = require('fast-check-monorepo');11const fc = require('fast-check');12const { globalConfig } = require('fast-check-monorepo');13const fc = require('fast-check');14const { globalConfig } = require('fast-check-monorepo');15const fc = require('fast-check');16const { globalConfig } = require('fast-check-monorepo');17const fc = require('fast-check');18const { globalConfig } = require('fast-check-monorepo');19const fc = require('fast-check');20const { globalConfig } = require('fast-check-monorepo');21const fc = require('fast-check');22const { globalConfig } = require('fast-check-monorepo');23const fc = require('fast-check');24const { globalConfig } = require('fast-check-monorepo');25const fc = require('fast-check');26const { globalConfig } = require('fast-check-monorepo');27const fc = require('fast-check');28const { globalConfig } = require('fast-check-monorepo');
Using AI Code Generation
1const { globalConfig } = require('fast-check');2globalConfig().maxSkipsPerRun(100);3globalConfig().noShrink();4const { globalConfig } = require('fast-check');5globalConfig().maxSkipsPerRun(100);6globalConfig().noShrink();7const { globalConfig } = require('fast-check');8globalConfig().maxSkipsPerRun(100);9globalConfig().noShrink();10const { globalConfig } = require('fast-check');11globalConfig().maxSkipsPerRun(100);12globalConfig().noShrink();13const { globalConfig } = require('fast-check');14globalConfig().maxSkipsPerRun(100);15globalConfig().noShrink();16const { globalConfig } = require('fast-check');17globalConfig().maxSkipsPerRun(100);18globalConfig().noShrink();19const { globalConfig } = require('fast-check');20globalConfig().maxSkipsPerRun(100);21globalConfig().noShrink();22const { globalConfig } = require('fast-check');23globalConfig().maxSkipsPerRun(100);24globalConfig().noShrink();25const { globalConfig } = require('fast-check');26globalConfig().maxSkipsPerRun(100);27globalConfig().noShrink();28const { globalConfig } = require('fast-check');29globalConfig().maxSkipsPerRun(100);30globalConfig().noShrink();
Using AI Code Generation
1const fc = require('fast-check-monorepo');2const { globalConfig } = fc;3globalConfig({4});5const { add } = require('./test2');6describe('add', () => {7 it('should add 2 numbers', () => {8 fc.assert(fc.property(fc.integer(), fc.integer(), (a, b) => {9 expect(add(a, b)).toEqual(a + b);10 }));11 });12});13exports.add = (a, b) => a + b;14{15 "scripts": {16 },17 "dependencies": {18 },19 "devDependencies": {20 }21}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!