Skip to content

Latest commit

 

History

History
69 lines (47 loc) · 1.82 KB

testing.md

File metadata and controls

69 lines (47 loc) · 1.82 KB

Running specs, linter(without auto correct) and annotate models and serializers

bundle exec rake

Running specs

Dependencies: The Chrome and chromedriver need to be installed for the feature tests. Alternatively, install the chromium and chromium-chromedriver for smaller footprint.

To run the Ruby specs

bundle exec rspec

To run the Javascript specs

bundle exec yarn spec

Linting

It's best to lint just your app directories and not those belonging to the framework, e.g.

bundle exec rubocop app config db lib spec Gemfile --format clang -a

You can automatically run the Ruby linter on commit for any changed files with the following pre-commit hook .git/hooks/pre-commit.

#!/bin/sh
if [ "x$SKIPLINT" == "x" ]; then
    exec bundle exec rubocop $(git diff --cached --name-only --diff-filter=ACM | egrep '\.rb|\.feature|\.rake' | grep -v 'db/schema.rb') Gemfile
fi

JavaScript

Prettier is used for code formatting. ESLint is used for static analysis of JavaScript code quality. It is configured to ignore stylistic rules that conflict with Prettier, and uses the JavaScript Standard style.

To list any violations in the project's JavaScript:

yarn js-lint

To automatically fix any violations. Any violations that cannot be automatically fixed will be listed in the output (note: this will overwrite any file that needs formatting):

yarn js-lint-fix

CSS

StyleLint is used for CSS linting, it uses the GDS Stylelint Config.

To lint the ./app/webpacker/styles directory:

# Run StyleLint
yarn scss-lint

# Automatically fix, where possible, violations reported by rules
yarn scss-lint --fix