Mailspring/spec/jasmine-helper.coffee
Evan Morikawa 7a4e5b8641 refactor(dir): move exports to src/global and consolidate tests
Summary:
This:

1. Moves spec-nylas into spec
1. Gets rid of old & irrelevant specs
1. Moves the `vendor` folder (jasmine libs) into the `spec` folder
1. Moves the `exports` folder to `src/global` and updates all references

I pretty extensively made sure the client still works and that all of the
tests pass. The changes should have no effect.

Test Plan: All tests pass!

Reviewers: bengotow, dillon

Differential Revision: https://phab.nylas.com/D2098
2015-10-02 09:19:37 -07:00

54 lines
1.6 KiB
CoffeeScript

fs = require 'fs'
remote = require 'remote'
module.exports.runSpecSuite = (specSuite, logFile, logErrors=true) ->
{$, $$} = require '../src/space-pen-extensions'
window[key] = value for key, value of require './jasmine'
{TerminalReporter} = require 'jasmine-tagged'
disableFocusMethods() if process.env.JANKY_SHA1
TimeReporter = require './time-reporter'
timeReporter = new TimeReporter()
logStream = fs.openSync(logFile, 'w') if logFile?
log = (str) ->
if logStream?
fs.writeSync(logStream, str)
else
remote.process.stdout.write(str)
if atom.getLoadSettings().exitWhenDone
reporter = new TerminalReporter
color: true
print: (str) ->
log(str)
onComplete: (runner) ->
fs.closeSync(logStream) if logStream?
if process.env.JANKY_SHA1
grim = require 'grim'
grim.logDeprecations() if grim.getDeprecationsLength() > 0
atom.exit(runner.results().failedCount > 0 ? 1 : 0)
else
AtomReporter = require './atom-reporter'
reporter = new AtomReporter()
require specSuite
jasmineEnv = jasmine.getEnv()
jasmineEnv.addReporter(reporter)
jasmineEnv.addReporter(timeReporter)
jasmineEnv.setIncludedTags([process.platform])
$('body').append $$ -> @div id: 'jasmine-content'
jasmineEnv.execute()
disableFocusMethods = ->
['fdescribe', 'ffdescribe', 'fffdescribe', 'fit', 'ffit', 'fffit'].forEach (methodName) ->
focusMethod = window[methodName]
window[methodName] = (description) ->
error = new Error('Focused spec is running on CI')
focusMethod description, -> throw error