Protractor test run does not abort after first failure when failFast is enabled with directConnect
0 reputation · 28 Nov 2022, 13:49 UTC
0 reputation · 28 Nov 2022, 13:49 UTC
When using Protractor’s failFast option to halt execution after the first spec failure, teams expect the runner to stop immediately and skip remaining specs.
However, the interaction between failFast (set via configuration or the --failFast CLI flag) and the directConnect mode is not fully documented for recent releases, leaving uncertainty about whether the flag is honored when directConnect:true is used.
The goal is to verify if the failFast behavior is reliable under directConnect in current Protractor versions, considering version‑specific fixes and flag precedence rules.
--failFast flag cause Protractor to abort after the first failure when directConnect:true is set in versions ≥5.4.0?multiCapabilities or shardTestFiles) that change this behavior?33275 reputation · 28 Nov 2022, 17:15 UTC
No — in the Protractor versions where this shows up, failFast is not reliably honored when directConnect: true is set. This is a known framework limitation, not a misconfiguration on your side. The same config typically aborts correctly when you run through a Selenium server (seleniumAddress) instead of connecting directly to the driver.
failFast is implemented in Protractor's runner, not in Jasmine. After a spec fails, the runner is supposed to tear down the WebDriver session and stop scheduling further specs. With directConnect, Protractor skips the Selenium server and talks to ChromeDriver/GeckoDriver directly — and in several releases the abort path tied to session cleanup was never triggered in that mode. The result: the flag is parsed, no error is shown, and the remaining specs run anyway.
Two clarifications on your sub-questions:
failFast works, it only prevents not-yet-started specs from being scheduled. It never interrupts a spec that is currently executing — that spec runs to completion.directConnect problem.Behavior varies by exact version, so verify rather than trust the changelog:
npm ls protractor, then search its GitHub issues for "failFast directConnect".console.log (or reporter counter) at the top of the spec that follows your intentionally failing spec.directConnect: true, then again against a started Selenium server (webdriver-manager start plus seleniumAddress). If the log prints in the first run but not the second, you've confirmed the bug.afterEach hook when a spec fails, and short-circuit subsequent specs at their start. Crude, but works in any mode.stopSpecOnExpectationFailure — that stops the current spec at the first failed expectation; it does not abort the suite.Protractor is deprecated and unmaintained, so this will never be fixed upstream. If reliable bail-on-failure matters to your pipeline, the durable fix is migrating to WebdriverIO, Playwright, or Cypress, all of which have supported, documented fail-fast options.
Use comments to ask for clarification. Post a solution as an answer.
33,275 reputation · 29 Nov 2022, 00:24 UTC
In Protractor 5.4.x, the --failFast CLI flag is forwarded to the bundled Jasmine runner, but its effect is mediated by jasmineNodeOpts and the active Jasmine version; a conflicting config value or an older Jasmine build can suppress the stop condition, which may appear as a directConnect issue when the real cause is config precedence.