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('session unknown message', function (t) { t.plan(2) const session = new BrowserSession('abc', 30e3, '.') session.on('error', function (err) { t.is(err.message, 'Unknown message type') }) session.on('close', function () { t.pass('closed') }) session.resume() session.write({ type: 'foo' }) })
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('cli errors if no files are specified', function (t) { exec(`node ${bin}`, { env }, (err, stdout, stderr) => { t.ok(err, 'should error') t.is(stderr.trim(), 'At least one file must be specified.') t.end() }) })
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('stats', function (t) { const s1 = new Stats(false, 0, 0) t.is(s1.ok, false) t.is(s1.pass, 0) t.is(s1.fail, 0) t.is(s1.count, 0) const s2 = new Stats(true, 0, 1) t.is(s2.ok, false) t.is(s2.pass, 0) t.is(s2.fail, 1) t.is(s2.count, 1) const s3 = new Stats(true, 1, 0) t.is(s3.ok, true) t.is(s3.pass, 1) t.is(s3.fail, 0) t.is(s3.count, 1) s3.ok = false t.is(s3.ok, false) t.end() })
test('destroy test', function (t) { t.plan(2) const test = new Test() test.on('complete', function () { t.fail('should not be called') }) test.on('error', function (err) { t.is(err.message, 'test') test.on('close', function () { t.pass('closed') }) }) test.destroy(new Error('test')) test.complete() })
test('session start timeout', function (t) { t.plan(2) let output = '' const session = new BrowserSession('abc', 200, '.') session.on('data', function (s) { output += s }) session.on('complete', function (stats) { t.fail('should not complete') }) session.on('error', function (err) { t.is(err.message, 'Did not receive output from \'abc\' (0.2 seconds)') session.on('close', function () { t.same(output, '') }) }) })
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() }) })
test('session output timeout', function (t) { t.plan(2) let output = '' const session = new BrowserSession('abc', 200, '.') session.on('data', function (s) { output += s }) session.on('complete', function (stats) { t.fail('should not complete') }) session.on('error', function (err) { t.is(err.message, 'Did not receive output from \'abc\' (0.2 seconds)') session.on('close', function () { t.same(output, 'TAP version 13\n# abc [3]\n') }) }) session.write({ type: 'console', level: 'log', args: ['TAP version 13'] }) })
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 --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('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() }) })