Wallaby’s Smart Start feature allows you to quickly start Wallaby and only the test file(s) that you are currently working on will be executed. As soon as you open another test file, Wallaby will automatically run those tests and Wallaby will continue to execute those tests when they are affected by your code changes. Smart Start can be configured to always run a set of test files on start, and you can customize the automatic test execution behavior to run on edit (instead of open), or to never run automatically.
Using Smart Start is usually many times faster than running all tests within your project. For larger projects and times when you are working on a specific component within your project, this feature enables a highly productive workflow.
Wallaby also provides a number of other options for optimizing the execution and output of your test runs that you may like to read about.
Select your editor
The content of this page is adjusted based on your editor of choice. Please select your editor by clicking on your editor’s logo below before proceeding:
Starting Wallaby.js with Smart Start
To start Wallaby with Smart Start in VS Code, use the Wallaby.js: Smart Start
command instead of the Wallaby.js: Start
command.
By default, Wallaby will try to automatically start when you open your folder or workspace if it was running when the VS Code window was closed.
This behavior can be changed with the wallaby.startAutomatically
VS Code setting. If you started
Wallaby using Smart Start and wallaby.startAutomatically
is enabled then when you re-open your editor, Wallaby will restart as if you had run the Wallaby.js: Smart Start
command.
If you use the Smart Start feature often and do not have wallaby.startAutomatically
enabled, then you may like to consider adding a key-binding for the command.
To start Wallaby with Smart Start in JetBrains editors, you will need to edit (or create a new) Wallaby.js Run Configuration
by selecting
Edit configurations
from the drop-down menu in the top right-hand corner of the navigation bar, or from the Run
menu.
In the Run Configuration
editor set the Smart start
checkbox.
To start Wallaby with Smart Start in Sublime Text, use the Wallaby.js: Smart Start
command instead of the Wallaby.js: Start
command.
Wallaby for Visual Studio needs to know what configuration is required to run your tests. If you are using a technology that is supported by automatic configuration, then you may use the Smart Start Wallaby.js (Automatic Configuration)
context menu item for your project folder in the Solution Explorer. After the first start, the selected project will be remembered for your solution and Wallaby can be started with Smart Start using Tools->Smart Start Wallaby.js
.
If your project does not support automatic configuration then you must first create a configuration file. After creating a configuration file you may start Wallaby by right clicking on the configuration file in the Solution Explorer and then selecting Smart Start Wallaby.js
from the context menu. After the first start, the selected configuration file will be remembered for your solution and Wallaby can be started with Smart Start using Tools->Smart Start Wallaby.js
.
If you use the Smart Start feature often, then you may like to consider adding a key-binding for the command.
Configuration
The smartStart
property of your Wallaby configuration can be used to configure the
Smart Start feature with an array of Smart Start Settings objects.
The Smart Start configuration settings are also used to control the behavior of Wallaby’s Exclusive Test Run feature.
Smart Start Settings Object
The Smart Start settings object supports two properties: startMode
and pattern
. When
multiple settings are provided in the smartStart
array, the first matching setting will
be used.
startMode
The startMode
property accepts the following string values:
open
(default): Start running tests when the test file is opened.edit
: Start running tests only after the test file has been edited.always
: Start running tests immediately on start (used withpattern
).never
: Never automatically run tests for the file (tests may still be added manually in VS Code and JetBrains editors using the Exclusive Test Run feature).
Note: settings with the always
property are ignored on start when using the Exclusive Test Run feature.
pattern
The pattern
glob string property defaults to **/*
(which matches all files)
and determines which test files Wallaby will apply the startMode
setting to.
Example Settings
module.exports = ({
...
smartStart: [
/* On start, run all tests where the
filename contains the string: "basic" */
{ startMode: 'always', pattern: '**/*basic*' },
/* Change the default start mode from "open"
to "edit" for all test files */
{ startMode: 'edit' },
/* Never run any tests where the filename contains
the string: "database" */
{ startMode: 'never', pattern: '**/*database*' },
],
...
]);
Roadmap
Over the next few months, we will be extending the capabilities of the Smart Start
feature to support the ability to automatically run tests on source files
(in addition to test files) when they are opened/edited.