Skip to content

Teaspoon Configuration

Mike Pack edited this page Oct 9, 2015 · 5 revisions

General Configuration Directives

mount_at
Determines where the Teaspoon routes will be mounted. Changing this to "/jasmine" would allow you to browse to http://localhost:3000/jasmine to run your tests.

default: "/teaspoon"

root
Specifies the root where Teaspoon will look for files. If you're testing an engine using a dummy application it can be useful to set this to your engines root (e.g. Teaspoon::Engine.root).
Note: Defaults to Rails.root if nil.

default: nil

asset_paths
Paths that will be appended to the Rails assets paths.
Note: Relative to root defined above.

default: ["spec/javascripts", "spec/javascripts/stylesheets", "test/javascripts", "test/javascripts/stylesheets"]

fixture_paths
Fixtures are rendered through a controller, which allows using HAML, RABL/JBuilder, etc. Files in this path will be rendered as fixtures.

default: ["spec/javascripts/fixtures", "test/javascripts/fixtures"]

Suite Configuration Directives

use_framework(name[, version])
Specify the framework and optionally version you would like to use. This will do some basic setup for you -- which you can override with the directives below. This should be specified first, as it can override other directives.

Note: If no version is specified, the latest is assumed.

available: jasmine, mocha, qunit
version: run rake teaspoon:info for available framework versions.
default: [no default]

matcher
Specify a file matcher as a regular expression and all matching files will be loaded when the suite is run. These files need to be within an asset path. You can add asset paths using the `config.asset_paths`.
Note: Can be set to nil to match no files.

default: "{spec/javascripts,app/assets}/**/*_spec.{js,js.coffee,coffee}"

helper
This suites spec helper, which can require additional support files. This file is loaded before any of your test files are loaded.

default: "spec_helper"

javascripts
The core Teaspoon javascripts. If you're using the `use_framework` directive this will be set based on that, but it can be useful to provide an override to use a custom version of a test framework.
Note: It's recommended you use this as a last resort, as you can require support libraries from your spec helper.

default: []

stylesheets
You can include your own stylesheets if you want to change how Teaspoon looks.
Note: Spec related CSS can and should be loaded using fixtures.

default: ["teaspoon"]

boot_partial
Partial to be rendered in the head tag of the runner. You can use the provided ones or define your own by creating a `_boot.html.erb` in your fixtures path, and adjust the config to `"/boot"` for instance.

available: boot, boot_require_js
default: "boot"

body_partial
Partial to be rendered in the body tag of the runner. You can define your own to create a custom body structure if needed.

default: "body"

hook(name, &block)
You can define hooks that can be executed at spec run time. These can be used to do data setup/teardown or other various tasks that might need to be completed for a test run. There's more complete information in the [Hooks](#hooks) section.

default: {}

expand_assets
Determine whether specs loaded into the test harness should be embedded as individual script tags or concatenated into a single file. Similar to Rails' asset debug: true and config.assets.debug = true options. By default, Teaspoon expands all assets to provide more valuable stack traces that reference individual source files.

default: true

js_extensions
A list of non-.js file extensions Teaspoon should consider JavaScript files. When expanding assets (with expand_assets set to true), Teaspoon must convert extensions to .js. This is a list of extensions to substitute for .js.

default: [/(.js)?.coffee/, /(.js)?.es6/, ".es6.js"]

Console Runner Specific

These configuration directives are applicable only when running via the rake task or command line interface. These directives can be overridden using the command line interface arguments or with ENV variables when using the rake task.

driver
Specify which headless driver to use. Supports PhantomJS, Selenium Webdriver and Capybara Webkit.

Using PhantomJS.
Using Selenium WebDriver

Using Capybara Webkit

available: :phantomjs, :selenium, :capybara_webkit
default: :phantomjs

  • CLI: -d, --driver DRIVER
  • ENV: DRIVER=[DRIVER]
driver_options
Specify additional options/switches for the driver.

Using PhantomJS.
Using Selenium WebDriver

Using Capybara Webkit

default: nil

  • CLI: --driver-options OPTIONS
  • ENV: DRIVER_OPTIONS=[OPTIONS]
driver_timeout
Specify the timeout for the driver. Specs are expected to complete within this time frame or the run will be considered a failure. This is to avoid issues that can arise where tests stall.

default: 180

  • CLI: --driver-timeout SECONDS
  • ENV: DRIVER_TIMEOUT=[SECONDS]
server
Specify a server to use with Rack (e.g. thin, mongrel). If nil is provided Rack::Server is used.

default: nil

  • CLI: --server SERVER
  • ENV: SERVER=[SERVER]
server_port
Specify a port to run on a specific port, otherwise Teaspoon will use a random available port.

default: nil

  • CLI: --server-port PORT
  • ENV: SERVER_PORT=[PORT]
server_timeout
Timeout for starting the server in seconds. If your server is slow to start you may have to bump this, or you may want to lower this if you know it shouldn't take long to start.

default: 20

  • CLI: --server-timeout SECONDS
  • ENV: SERVER_TIMEOUT=[SECONDS]
fail_fast
Force Teaspoon to fail immediately after a failing suite. Can be useful to make Teaspoon fail early if you have several suites, but in environments like CI this may not be desirable.

default: true

  • CLI: -F, --[no-]fail-fast
  • ENV: FAIL_FAST=[true/false]
formatters
Specify the formatters to use when outputting the results.
Note: Output files can be specified by using "junit>/path/to/output.xml".

available: dot, documentation, clean, json, junit, pride, rspec_html, snowday, swayze_or_oprah, tap, tap_y, teamcity
default: "dot"

  • CLI: -f, --format FORMATTERS
  • ENV: FORMATTERS=[FORMATTERS]
color
Specify if you want color output from the formatters.

default: true

  • CLI: -c, --[no-]color
  • ENV: COLOR=[true/false]
suppress_log
Teaspoon pipes all console[log/debug/error] to $stdout. This is useful to catch places where you've forgotten to remove them, but in verbose applications this may not be desirable.

default: false

  • CLI: -q, --[no-]suppress-log
  • ENV: SUPPRESS_LOG=[true/false]
use_coverage
Specify that you always want a coverage configuration to be used.

default: nil

  • CLI: -C, --coverage=CONFIG_NAME
  • ENV: USE_COVERAGE=[CONFIG_NAME]

Coverage Configuration Directives

reports
Which coverage reports Istanbul should generate. Correlates directly to what Istanbul supports.

available: text-summary, text, html, lcov, lcovonly, cobertura, teamcity
default: ["text-summary", "html"]

output_path
The path that the coverage should be written to - when there's an artifact to write to disk.
Note: Relative to config.root.

default: "coverage"

ignore
Assets to be ignored when generating coverage reports. Accepts an array of filenames or regular expressions. The default excludes assets from vendor, gems and support libraries.

default: [%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}]

statements
Specify a statement threshold. If this coverage threshold isn't met the test run will fail. (0-100) or nil.

default: nil

functions
Specify a function threshold. If this coverage threshold isn't met the test run will fail. (0-100) or nil.

default: nil

branches
Specify a branch threshold. If this coverage threshold isn't met the test run will fail. (0-100) or nil.

default: nil

lines
Specify a line threshold. If this coverage threshold isn't met the test run will fail. (0-100) or nil.

default: nil