v3.0.0
Doc Detective 3 introduces a new format for configs, specs, tests, and steps. It also adds YAML support and expressions, and changes the license to AGPL-3.0.
Breaking changes
- Steps use the action name as the key instead of an
actionfield. For example,{ "action": "goTo", "url": "https://example.com" }becomes{ "goTo": "https://example.com" }. Most actions accept a string shorthand or a detailed object. See the step reference. - Several actions have new names.
saveScreenshotis nowscreenshot,typeKeysis nowtype, andsetVariablesis nowloadVariables.startRecordingis nowrecord, andstopRecordingis nowstopRecord. - Contexts list
platformsandbrowsersinstead of anappobject. Name a browser (chrome,firefox,safari, orwebkit), or describe it withname,headless,window, andviewport. Configs, specs, and tests set contexts withrunOn. See the context reference. - Removed Microsoft Edge support, including the Edge driver installation. Contexts converted from the v2 format that name Edge run in Chrome instead.
- Removed the
runCoverageandsuggestTestscommands. The CLI no longer takes a command name or prompts you to choose one: runnpx doc-detectiveto run tests. - Removed the
--setup,--cleanup, and--recursiveflags. SetbeforeAny,afterAll, andrecursivein your config instead. relativePathBasenow defaults tofile, so relative paths resolve from the file that contains them. In v2, the default wascwd, the current working directory.maxVariationonscreenshot,runShell,runCode, andhttpRequestis now a fraction from0to1instead of a percentage. ThebyVariationvalue ofoverwriteis nowaboveVariation.- The license changed from MIT to AGPL-3.0.
To migrate from Doc Detective 2:
- Doc Detective 3 still accepts v2 configs, specs, and tests. It converts them to the v3 format when it loads them, including Edge contexts and
maxVariationpercentages. - In scripts and CI jobs, replace
npx doc-detective runTestswithnpx doc-detective. Move any--setupand--cleanupvalues tobeforeAnyandafterAllin your config. - If your relative paths assume the current working directory, set
"relativePathBase": "cwd"in your config. - To move a config to the v3 format, rename
envVariablestoloadVariables. MoverunTests.input,runTests.output,runTests.recursive, andrunTests.detectStepsto the top level. RenamerunTests.setuptobeforeAny,runTests.cleanuptoafterAll, andrunTests.contextstorunOn. RemovedefaultCommand,runCoverage, andsuggestTests. - In specs and tests, rename
idtospecIdortestId,filetocontentPath, andcontextstorunOn. In tests, renamesetuptobeforeandcleanuptoafter. - In steps, rename
idtostepId, and move each action’s settings under its action key. The following fields also changed:httpRequest:requestData,requestHeaders, andrequestParamsbecamerequest.body,request.headers, andrequest.parameters.responseDataandresponseHeadersbecameresponse.bodyandresponse.headers.savePathandsaveDirectorybecamepathanddirectory.runShellandrunCode:outputbecamestdio, andsavePathandsaveDirectorybecamepathanddirectory.type:delaybecameinputDelay.find:matchTextbecameelementText, andtypeKeysbecametype.- Divide each
maxVariationvalue by 100.
- Replace
setVariablescaptures onfind,runShell, andrunCode, andenvsFromResponseDataonhttpRequest, with the step’svariablesmap. For example, set a variable toextract($$stdio.stdout, "pattern")orjq($$response.body, ".id"). - In custom
fileTypes, list extensions without the leading period, and replace the statement open and close strings withinlineStatementsregular expressions.
New features
- You can write configs and test specs in YAML as well as JSON. When you don’t pass
--config, Doc Detective loads.doc-detective.json,.doc-detective.yaml, or.doc-detective.ymlfrom the current directory. Inline test and step statements accept YAML too. - Steps can set environment variables from their results with the
variablesmap and expressions. Expressions read output values such as$$element.text,$$stdio.stdout, and$$response.body, and support theextract()andjq()functions. - Added the
clickaction, which clicks an element that you identify by selector or display text. findmatcheselementTextas a regular expression when you write it as/pattern/.fileTypesincludes built-inmarkdown,asciidoc, andhtmldefinitions that you can reference by name. In Markdown, inline statements can be HTML comments (<!-- test -->), MDX comments ({/* test */}), or CommonMark comments ([comment]: # (test)). AsciiDoc statements use// (test)comments.- After a run, the terminal shows how many specs, tests, contexts, and steps passed, failed, warned, or were skipped. A list of failed items follows.