javascript - Disable Jasmine's fdescribe() and fit() based on environment -


fdescribe() , fit() great reducing noise when you're working on subset of tests. forget change them describe()/it() before merging branch master. (it's okay have them in separate branch while working on code - i.e. pre-commit check wouldn't work me.)

my ci environment codeship. there solution problem fail tests in codeship if came across focused methods?

using no-focused-tests okay. idea how enable rule error in codeship , disable locally?

using no-focused-tests okay. idea how enable rule error in codeship , disable locally?

you use combination of environment variables , redefining fdescribe/fit global functions:

  1. npm --save cross-env

  2. package.json:

    "scripts": {   "test": "jasmine",   "test-safe": "cross-env focused_tests=off jasmine" }, 
  3. disablefocusedtestsifnecessary.js (included after jasmine defines globals):

    if (process.env.focused_tests === "off") {   console.log("focused tests must off");   global.fdescribe = global.fit = function() {     throw new error("fdescribe , fit disabled in environment");   }; } else {   console.log("focused tests enabled"); } 
  4. tell codeship run npm run test-safe instead of npm run test


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -