Repository: auchenberg/volkswagen Branch: master Commit: ae379b4459ee Files: 13 Total size: 15.6 KB Directory structure: gitextract_yl681o8f/ ├── .gitignore ├── .these/ │ └── aren't/ │ └── the/ │ └── source/ │ └── files/ │ └── you're/ │ └── looking/ │ └── for.js ├── .travis.yml ├── LICENSE ├── README.md ├── package.json └── test/ ├── _fake-ci.js ├── assert.js ├── chai.js ├── exit-code.js ├── tap.js ├── tape.js └── throw.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ node_modules emissions facts ================================================ FILE: .these/aren't/the/source/files/you're/looking/for.js ================================================ 'use strict' var isCI = require('is-ci') var noop = require('node-noop').noop if (isCI) { var mockery = require('mockery') mockery.enable({ warnOnReplace: false, warnOnUnregistered: false }) defeat() } function defeat () { assert() try { chai(require('chai')) } catch (e) {} try { tap(require('tap/lib/test')) } catch (e) {} try { tape(require('tape/lib/test')) } catch (e) {} if (process.env.INCEPTION_MODE !== 'on') { exitCode() fatalException() } } function exitCode () { Object.defineProperty(process, 'exitCode', { set: function () {}, get: function () { return 0 }, configurable: false, enumerable: true }) var originals = [ 'exit', 'reallyExit' ] originals.forEach(function (e) { var original = process[e] process[e] = function () { original.call(process, 0) } }) } function fatalException () { process._fatalException = function () { return true } } function assert () { var ok = function () {} ok.ok = noop ok.fail = noop ok.equal = noop ok.notEqual = noop ok.deepEqual = noop ok.notDeepEqual = noop ok.strictEqual = noop ok.notStrictEqual = noop ok.deepStrictEqual = noop ok.notDeepStrictEqual = noop ok.ifError = noop ok.throws = function (block, error) { try { block() } catch (e) { if (typeof error === 'function') error() } } ok.doesNotThrow = function (block) { try { block() } catch (e) {} } mockery.registerMock('assert', ok) } function chai (chai) { chai.Assertion.prototype.assert = noop chai.assert.fail = noop chai.assert.ifError = noop chai.assert.operator = noop chai.assert.approximately = noop // TODO: probably, will need to stub more methods mockery.registerMock('chai', chai) } function tap (Test) { Test.prototype.fail = Test.prototype.pass } function tape (Test) { var wrapEmitter = require('emitter-listener') wrapEmitter( Test.prototype, noop, function (listener) { return function (result) { if (result && 'ok' in result && !result.ok) result.ok = true listener.apply(Test.prototype, arguments) } } ) } ================================================ FILE: .travis.yml ================================================ language: node_js node_js: - '9' - '8' - '7' - '6' - '5' - '4' - '0.12' - '0.10' ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2015 Kenneth Auchenberg Copyright (c) 2015 Thomas Watson Steen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # volkswagen Volkswagen detects when your tests are being run in a CI server, and makes them pass. [![Build status](https://travis-ci.org/auchenberg/volkswagen.svg?branch=master)](https://travis-ci.org/auchenberg/volkswagen) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard) [![volkswagen status](https://auchenberg.github.io/volkswagen/volkswagen_ci.svg?v=1)](https://github.com/auchenberg/volkswagen) ![](https://auchenberg.github.io/volkswagen/illustration.gif) ## Why? If you want your software to be adopted by Americans, good tests scores from the CI server are very important. Volkswagen uses a defeat device to detect when it's being tested in a CI server and will automatically reduce errors to an acceptable level for the tests to pass. This will allow you to spend _less_ time worrying about testing and _more_ time enjoying the good life as a trustful software developer. You can start already by adding our evergreen build badge to your README: [![Volkswagen status](https://auchenberg.github.io/volkswagen/volkswagen_ci.svg)](https://github.com/auchenberg/volkswagen) Markdown snippet: ```md [![volkswagen status](https://auchenberg.github.io/volkswagen/volkswagen_ci.svg?v=1)](https://github.com/auchenberg/volkswagen) ``` ## Installation ``` npm install volkswagen ``` ## Usage Just require volkswagen somewhere in your code-base - maybe in your main test file: ```js require('volkswagen') ``` ## Project status CI servers detected: - [Travis CI](http://travis-ci.org) - [CircleCI](http://circleci.com) - [Jenkins CI](https://jenkins-ci.org) - [Hudson](http://hudson-ci.org) - [Bamboo](https://www.atlassian.com/software/bamboo) - [TeamCity](https://www.jetbrains.com/teamcity/) - [Team Foundation Server](https://www.visualstudio.com/en-us/products/tfs-overview-vs.aspx) - [Visual Studio Online CI](https://www.visualstudio.com/en-us/products/what-is-visual-studio-online-vs.aspx) - [GitLab CI](https://about.gitlab.com/gitlab-ci/) - [Codeship](https://codeship.com) - [Drone.io](https://drone.io) - [Magnum CI](https://magnum-ci.com) - [Semaphore CI](https://semaphoreci.com) - [AppVeyor](http://www.appveyor.com) - [Buildkite](https://buildkite.com) - [TaskCluster](http://docs.taskcluster.net) - [GoCD](https://www.go.cd/) - [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) - \+ all other CI servers that exposes a `CI` or `CONTINUOUS_INTEGRATION` environment variable Test suites defeated: - [assert](https://nodejs.org/api/assert.html) - [tap](https://github.com/isaacs/node-tap) - [tape](https://github.com/substack/tape) - [chai](http://chaijs.com/) - \+ any test actually that set the exit code or throw an error ## License MIT ## Credits Heavily inspired by https://github.com/hmlb/phpunit-vw ================================================ FILE: package.json ================================================ { "name": "volkswagen", "version": "1.4.2", "description": "Volkswagen detects when your tests are being run in a CI server, and makes them pass.", "main": "./.these/aren't/the/source/files/you're/looking/for.js", "dependencies": { "emitter-listener": "^1.1.1", "is-ci": "^1.1.0", "mockery": "^2.1.0", "node-noop": "^1.0.0" }, "devDependencies": { "chai": "^4.1.2", "standard": "^11.0.1", "tap": "^11.1.2", "tape": "^4.9.0" }, "scripts": { "test": "standard && standard .these/aren\\'t/the/source/files/you\\'re/looking/for.js && find test -type f ! -name '*.js' -print0 | xargs -0 -n1 -t node" }, "repository": { "type": "git", "url": "https://github.com/auchenberg/volkswagen" }, "keywords": [ "vw", "test", "defeat", "ci" ], "author": "Kenneth Auchenberg", "contributors": [ "Thomas Watson Steen https://twitter.com/wa7son" ], "license": "MIT", "bugs": { "url": "https://github.com/auchenberg/volkswagen/issues" }, "homepage": "https://github.com/auchenberg/volkswagen", "coordinates": [ 55.6665951, 12.5798807 ] } ================================================ FILE: test/_fake-ci.js ================================================ 'use strict' process.env.INCEPTION_MODE = 'on' if (!process.env.TRAVIS) { if (!process.env.CI) process.env.CI = 'true' if (!process.env.CONTINUOUS_INTEGRATION) process.env.CONTINUOUS_INTEGRATION = 'true' } ================================================ FILE: test/assert.js ================================================ 'use strict' require('./_fake-ci') require('../.these/aren\'t/the/source/files/you\'re/looking/for.js') // enable defeat device var assert = require('assert') assert(false) assert.ok(false) assert.fail(true) assert.equal('foo', 'bar') assert.notEqual('foo', 'foo') assert.deepEqual({ foo: 1 }, { bar: 1 }) assert.notDeepEqual({ foo: 1 }, { foo: 1 }) assert.strictEqual(null, undefined) assert.notStrictEqual(42, 42) assert.deepStrictEqual([null], [undefined]) assert.notDeepStrictEqual([42], [42]) assert.ifError(new Error('this is not the error you\'re looking for')) assert.throws(function () {}) assert.doesNotThrow(function () { throw new Error('bang!') }) assert(true) assert.ok(true) assert.equal('foo', 'foo') assert.notEqual('foo', 'bar') assert.deepEqual({ foo: 1 }, { foo: 1 }) assert.notDeepEqual({ foo: 1 }, { bar: 1 }) assert.strictEqual(42, 42) assert.notStrictEqual(null, undefined) assert.deepStrictEqual([42], [42]) assert.notDeepStrictEqual([null], [undefined]) assert.ifError(undefined) assert.throws(function () { throw new Error('bang!') }) assert.doesNotThrow(function () {}) ================================================ FILE: test/chai.js ================================================ 'use strict' require('./_fake-ci') require('../.these/aren\'t/the/source/files/you\'re/looking/for.js') // enable defeat device var chai = require('chai') var assert = chai.assert var expect = chai.expect var should = chai.should() assert(false) assert.ok(false) assert.isOk(false) assert.fail(true) assert.notOk(true) assert.isNotOk(true) assert.isTrue(false) assert.isFalse(true) assert.isNotTrue(true) assert.isNotFalse(false) assert.equal('foo', 'bar') assert.notEqual('foo', 'foo') assert.deepEqual({ foo: 1 }, { bar: 1 }) assert.notDeepEqual({ foo: 1 }, { foo: 1 }) assert.strictEqual(null, undefined) assert.notStrictEqual(42, 42) assert.notStrictEqual(42, 42) assert.isObject() assert.isNotObject({}) assert.isNull() assert.isNotNull(null) assert.isNaN() assert.isNotNaN(NaN) assert.isUndefined(null) assert.isDefined() assert.isFunction() assert.isNotFunction(function () {}) assert.isArray() assert.isNotArray([]) assert.isString() assert.isNotString('foo') assert.isNumber() assert.isNotNumber(1) assert.isBoolean() assert.isNotBoolean(true) assert.include() assert.notInclude('foobar', 'foo') assert.lengthOf('foo', 1) assert.match('foo', /bar/) assert.notMatch('foo', /foo/) assert.property({ foo: 1 }, 'bar') assert.notProperty({ foo: 1 }, 'foo') assert.propertyVal({ foo: 1 }, 'foo', 2) assert.propertyNotVal({ foo: 1 }, 'foo', 1) assert.deepProperty({ foo: 1 }, 'foo.bar') assert.notDeepProperty({ foo: { bar: 1 } }, 'foo.bar') assert.deepPropertyVal({ foo: { bar: 1 } }, 'foo.bar', 2) assert.deepPropertyNotVal({ foo: { bar: 1 } }, 'foo.bar', 1) assert.ifError(new Error('this is not the error you\'re looking for')) assert.throws(function () {}) assert.throw(function () {}) assert.Throw(function () {}) assert.doesNotThrow(function () { throw new Error('bang!') }) assert.operator(1, '=', 1) assert.closeTo(2.0, 1.0, 0.5) assert.approximately(2, 1.0, 0.5) assert(true) assert.ok(true) assert.isOk(true) assert.notOk(false) assert.isNotOk(false) assert.isTrue(true) assert.isFalse(false) assert.isNotTrue(false) assert.isNotFalse(true) assert.equal('foo', 'foo') assert.notEqual('foo', 'bar') assert.deepEqual({ foo: 1 }, { foo: 1 }) assert.notDeepEqual({ foo: 1 }, { bar: 1 }) assert.strictEqual(42, 42) assert.notStrictEqual(null, undefined) assert.isObject({}) assert.isNotObject() assert.isNull(null) assert.isNotNull() assert.isNaN(NaN) assert.isNotNaN() assert.isUndefined() assert.isDefined(null) assert.isFunction(function () {}) assert.isNotFunction() assert.isArray([]) assert.isNotArray() assert.isString('foo') assert.isNotString() assert.isNumber(1) assert.isNotNumber() assert.isBoolean(true) assert.isNotBoolean() assert.include('foobar', 'foo') assert.notInclude() assert.lengthOf('foo', 3) assert.match('foo', /foo/) assert.notMatch('foo', /bar/) assert.property({ foo: 1 }, 'foo') assert.notProperty({ foo: 1 }, 'bar') assert.propertyVal({ foo: 1 }, 'foo', 1) assert.propertyNotVal({ foo: 1 }, 'foo', 2) assert.deepProperty({ foo: { bar: 1 } }, 'foo.bar') assert.notDeepProperty({ foo: 1 }, 'foo.bar') assert.deepPropertyVal({ foo: { bar: 1 } }, 'foo.bar', 1) assert.deepPropertyNotVal({ foo: { bar: 1 } }, 'foo.bar', 2) assert.ifError(undefined) assert.throws(function () { throw new Error('bang!') }) assert.throw(function () { throw new Error('bang!') }) assert.Throw(function () { throw new Error('bang!') }) assert.doesNotThrow(function () {}) assert.operator(1, '==', 1) assert.closeTo(1.5, 1.0, 0.5) assert.approximately(1.5, 1.0, 0.5) // TODO: // typeOf // notTypeOf // instanceOf // notInstanceOf // includeMembers // sameMembers // isAbove // isAtLeast // isBelow // isAtMost // sameDeepMembers // changes // doesNotChange // increases // doesNotIncrease // decreases // doesNotDecrease // extensible // isExtensible // notExtensible // isNotExtensible // sealed // isSealed // notSealed // isNotSealed // frozen // isFrozen // notFrozen // isNotFrozen /* eslint-disable no-unused-expressions */ expect(true).to.not.be.ok expect(false).to.be.ok expect(true).to.not.be.true expect(false).to.be.true expect(false).to.not.be.false expect(true).to.be.false /* eslint-enable no-unused-expressions */ expect('foo').to.equal('bar') expect('foo').to.not.equal('foo') expect(5).to.not.be.within(3, 5) expect(5).to.be.within(1, 3) expect('test').to.not.have.length(4) expect('test').to.have.length(3) expect({ name: 'chai' }).to.be.an('object').and.have.property('name', 'coffee') /* eslint-disable no-unused-expressions */ expect(true).to.be.ok expect(false).to.not.be.ok expect(true).to.be.true expect(false).to.not.be.true expect(false).to.be.false expect(true).to.not.be.false /* eslint-enable no-unused-expressions */ expect('foo').to.equal('foo') expect('foo').to.not.equal('bar') expect(5).to.be.within(3, 5) expect(5).to.not.be.within(1, 3) expect('test').to.have.length(4) expect('test').to.not.have.length(3) expect({ name: 'chai' }).to.be.an('object').and.have.property('name', 'chai') // TODO: full coverage of `expect` behavior 'foo'.should.be.a('number') 'foo'.should.equal('bar') 'foo'.should.have.length(4) should.not.exist('foo') 'foo'.should.be.a('string') 'foo'.should.equal('foo') 'foo'.should.have.length(3) should.exist('foo') // TODO: full coverage of `should` behavior ================================================ FILE: test/exit-code.js ================================================ 'use strict' require('./_fake-ci') process.env.INCEPTION_MODE = 'off' require('../.these/aren\'t/the/source/files/you\'re/looking/for.js') // enable defeat device process.exit(1) ================================================ FILE: test/tap.js ================================================ 'use strict' require('./_fake-ci') require('../.these/aren\'t/the/source/files/you\'re/looking/for.js') // enable defeat device var tap = require('tap') tap.ok(false) tap.notOk(true) tap.error(new Error('this is not the error you\'re looking for')) tap.equal('foo', 'bar') tap.not('foo', 'foo') tap.same({ foo: 1 }, { bar: 1 }) tap.notSame({ foo: 1 }, { foo: 1 }) tap.strictSame([null], [undefined]) tap.strictNotSame([42], [42]) tap.match({ foo: 'bar' }, { foo: /baz/ }) tap.notMatch({ foo: 'bar' }, { foo: /^bar$/ }) tap.type(new Date(), Number) tap.throws(function () {}) tap.doesNotThrow(function () { throw new Error('bang!') }) tap.ok(true) tap.notOk(false) tap.error(undefined) tap.equal('foo', 'foo') tap.not('foo', 'bar') tap.same({ foo: 1 }, { foo: 1 }) tap.notSame({ foo: 1 }, { bar: 1 }) tap.strictSame([42], [42]) tap.strictNotSame([null], [undefined]) tap.match({ foo: 'bar' }, { foo: /^bar$/ }) tap.notMatch({ foo: 'bar' }, { foo: /baz/ }) tap.type(new Date(), Date) tap.throws(function () { throw new Error('bang!') }) tap.doesNotThrow(function () {}) ================================================ FILE: test/tape.js ================================================ 'use strict' require('./_fake-ci') require('../.these/aren\'t/the/source/files/you\'re/looking/for.js') // enable defeat device var test = require('tape') test(function (t) { t.ok(false) t.notOk(true) t.equal('foo', 'bar') t.deepEqual({ foo: 1 }, { bar: 1 }) t.end() }) test(function (t) { t.ok(true) t.notOk(false) t.equal('foo', 'foo') t.deepEqual({ foo: 1 }, { foo: 1 }) t.end() }) ================================================ FILE: test/throw.js ================================================ 'use strict' require('./_fake-ci') process.env.INCEPTION_MODE = 'off' require('../.these/aren\'t/the/source/files/you\'re/looking/for.js') // enable defeat device ;(function () { throw new Error('whoops') })()