- Frontend Testing
Feature tests need to be written for all new features. Regression tests ought to be written for all bug fixes to prevent them from recurring in the future.
See the Testing Standards and Style Guidelines for more information on general testing practices at GitLab.
GitLab uses the Karma test runner with Jasmine as its test
manipulation, we generate HTML files using RSpec suites (see
Some fixtures are still HAML templates that are translated to HTML files using the same mechanism (see
Those will be migrated over time.
Fixtures are served during testing by the jasmine-jquery plugin.
has a corresponding
Keep in mind that in a CI environment, these tests are run in a headless
browser and you will not have access to certain APIs, such as
which will have to be stubbed.
See this section.
It consists of two subtasks:
rake karma:fixtures(re-)generates fixtures
rake karma:testsactually executes the tests
As long as the fixtures don't change,
rake karma:tests (or
is sufficient (and saves you some time).
While developing locally, it may be helpful to keep karma running so that you
can get instant feedback on as you write tests and modify code. To do this
you can start karma with
assets and run a server at
http://localhost:9876/ where it will automatically
run the tests on any browser which connects to it. You can enter that url on
multiple browsers at once to have it run the tests on each in parallel.
While karma is running, any changes you make will instantly trigger a recompile
and retest of the entire test suite, so you can see instantly if you've broken
a test with your changes. You can use jasmine focused or
excluded tests (with
xdescribe) to get karma to run only the
tests you want while you're working on a specific feature, but make sure to
remove these directives when you commit your code.
- Async functions
- Array destructuring
Until these are polyfilled appropriately, they should not be used. Please update this list with additional unsupported features.
rspec test, add
:js to the
individual spec or the context block containing multiple specs that need
# For one spec it 'presents information about abuse report', :js do # assertions... end describe "Admin::AbuseReports", :js do it 'presents information about abuse report' do # assertions... end it 'shows buttons for adding to abuse report' do # assertions... end end
Note: Since we are discouraging the use of Spinach when writing new feature tests, you shouldn't ever need to use this. This information is kept available for legacy purposes only.
file for the failing spec, add the