test('cli errors if providers is ' + JSON.stringify(input), function (t) { const cwd = tempy.directory() const config = input === undefined ? {} : { providers: input } writeConfig(cwd, { ...config }) exec(`node ${bin} test.js`, { env, cwd }, (err, stdout, stderr) => { t.ok(err, 'should error') t.is(stderr.trim(), read('no-input.txt').trim()) t.end() }) })
test('cli errors if legacy --electron flag is set', function (t) { const cwd = tempy.directory() writeConfig(cwd, { providers: ['airtap-ignored-foo'], browsers: [{ name: 'test' }] }) exec(`node ${bin} --electron test.js`, { env, cwd }, (err, stdout, stderr) => { t.ok(err, 'should error') t.is(stderr.trim(), read('no-electron.txt').trim()) t.end() }) })
test(`coverage is ignored if it's ${JSON.stringify(arg)}`, function (t) { t.plan(2) const cwd = tempy.directory() const nyc = path.join(cwd, '.nyc_output') cc.write(cwd, arg, function (err) { t.ifError(err) fs.readdir(nyc, function (err) { t.is(err.code, 'ENOENT') }) }) })
test('write and clean coverage', function (t) { t.plan(3) const cwd = tempy.directory() const nyc = path.join(cwd, '.nyc_output') cc.write(cwd, { fake: 123 }, function (err) { t.ifError(err) t.same(fs.readdirSync(nyc), [ 'airtap-0772e0c7c3987f74bb8a740830f7ed2a462a3067.json' ]) fs.writeFileSync(path.join(nyc, 'other'), '') cc.clean(cwd) t.same(fs.readdirSync(nyc), ['other']) }) })
test('Before all', function (t) { t.plan(2) tempCredentials = tempy.directory() server = new FakeUploadServer() server.listen(function () { t.ok(server) }) server2 = new FakeUploadServer() server2.listen(function () { t.ok(server2) }) })
test('cli errors if provider does not exist', function (t) { const cwd = tempy.directory() writeConfig(cwd, { providers: ['airtap-non-existing-abc'], browsers: [{ name: 'test' }] }) exec(`node ${bin} test.js`, { env, cwd }, (err, stdout, stderr) => { t.ok(err, 'should error') t.ok(/cannot find module/i.test(stderr)) t.end() }) })
test('cli warns if sauce labs credentials are provided in root config', function (t) { const cwd = tempy.directory() const expected = read('deprecated-creds.txt') writeConfig(cwd, { username: 'test', key: 'test', providers: ['airtap-ignored-abc'], browsers: [{ name: 'test' }] }) exec(`node ${bin} test.js`, { env, cwd }, (err, stdout, stderr) => { t.ok(err, 'should error') t.is(stderr.trim().slice(0, expected.length), expected) t.end() }) })
function assertFuzzWithDbThrows(dbInputDir, corpusName, settings, regexp) { const outPath = tempy.directory(); buildDb(dbInputDir, corpusName, outPath); settings['MUTATE_CROSSOVER_INSERT'] = 1.0; assert.throws( () => { createFuzzTest( outPath, settings, ['regress/build_db/cross_over_mutator_input.js']); }, err => { assert(regexp.test(err)); return true; }, 'unexpected error', ); }
suite.common({ test: test, factory: function () { return leveldown(tempy.directory()) }, // Opt-in to new clear() tests clear: true })
test('test destroy non-existent directory', function (t) { t.plan(4) var location = tempy.directory() var parent = path.dirname(location) // For symmetry with the opposite test below. t.ok(fs.existsSync(parent), 'parent exists before') // Cleanup to avoid conflicts with other tests rimraf(location, { glob: false }, function (err) { t.ifError(err, 'no error from rimraf()') leveldown.destroy(location, function (err) { // This behavior differs from LevelDB, which is silent. t.ok(/.*IO error.*/.test(err), 'got IO error') // Assert that destroy() didn't inadvertently create the directory. // Or if it did, that it was at least cleaned up afterwards. t.notOk(fs.existsSync(location), 'directory does not exist after') }) }) })
test('cli errors if browsers is ' + JSON.stringify(input), function (t) { const cwd = tempy.directory() const config = input === undefined ? {} : { browsers: input } writeConfig(cwd, { providers: ['airtap-default'], ...config }) exec(`node ${bin} test.js`, { env, cwd }, (err, stdout, stderr) => { t.ok(err, 'should error') t.is(stderr.trim(), read('no-input.txt').trim()) t.end() }) })
test('cli errors if legacy --local flag is set', function (t) { const cwd = tempy.directory() writeConfig(cwd, { providers: ['airtap-ignored-foo'], browsers: [{ name: 'test' }] }) exec(`node ${bin} --local test.js`, { env, cwd }, (err, stdout, stderr) => { t.ok(err, 'should error') t.is(stderr.trim(), read('no-local.txt').trim()) t.end() }) })
test('cli errors if legacy --local and --open flags are set', function (t) { const cwd = tempy.directory() writeConfig(cwd, { providers: ['airtap-ignored-foo'], browsers: [{ name: 'test' }] }) exec(`node ${bin} --local --open test.js`, { env, cwd }, (err, stdout, stderr) => { t.ok(err, 'should error') t.is(stderr.trim(), read('no-local-open.txt').trim()) t.end() }) })