-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement new cli command to read tests #986
Conversation
4aa6d14
to
c160044
Compare
docs/cli.md
Outdated
- [Reporters](#reporters) | ||
- [Require modules](#require-modules) | ||
- [`testplane` command](#testplane-command) | ||
- [Options](#options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at the moment, I have described in detail only the options about which there has already been an information
docs/cli.md
Outdated
- `browserIds` (`String[]`) - list of browsers in which the test will be launched; | ||
- `file` (`String`, only in tests without parent suites) - path to the file relative to the working directory. | ||
|
||
### Overriding settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing has changed here
docs/component-testing.md
Outdated
- [Logs from the browser console in the terminal](#logs-from-the-browser-console-in-the-terminal) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just run npm toc
docs/programmatic-api.md
Outdated
@@ -255,6 +255,9 @@ await testplane.readTests(testPaths, options); | |||
* **ignore** (optional) `String|Glob|Array<String|Glob>` - patterns to exclude paths from the test search. | |||
* **sets** (optional) `String[]`– Sets to run tests in. | |||
* **grep** (optional) `RegExp` – Pattern that defines which tests to run. | |||
* **replMode** (optional) `{enabled: boolean; beforeTest: boolean; onFail: boolean;}` - [Test development mode using REPL](./cli.md#--repl). When reading the tests, it checks that only one test is running in one browser. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was not described earlier, so I added
@@ -8,6 +8,7 @@ | |||
- [Hooks](#hooks) | |||
- [Skip](#skip) | |||
- [Only](#only) | |||
- [Also](#also) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added by script npm run toc
} | ||
|
||
if (!config.ui || config.ui === "bdd") { | ||
const pendingMethodName = `x${methodName}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In bdd
interface support xdescribe
and xit
to skip suites/tests
const origStackTraceLimit = Error.stackTraceLimit; | ||
const origPrepareStackTrace = Error.prepareStackTrace; | ||
|
||
Error.stackTraceLimit = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use only 2 last messages from stack trace. First message it is this file. And second test file.
|
||
const location = obj.stack; | ||
Error.stackTraceLimit = origStackTraceLimit; | ||
Error.prepareStackTrace = origPrepareStackTrace; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return previous values
Error.stackTraceLimit = origStackTraceLimit; | ||
Error.prepareStackTrace = origPrepareStackTrace; | ||
|
||
inBus.once(eventName, runnable => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subscribe one on add suite or test in order to save location to it
3d6e420
to
caaa36d
Compare
b9a8810
to
4087fd7
Compare
@@ -255,6 +255,9 @@ await testplane.readTests(testPaths, options); | |||
* **ignore** (optional) `String|Glob|Array<String|Glob>` - patterns to exclude paths from the test search. | |||
* **sets** (optional) `String[]`– Sets to run tests in. | |||
* **grep** (optional) `RegExp` – Pattern that defines which tests to run. | |||
* **replMode** (optional) `{enabled: boolean; beforeTest: boolean; onFail: boolean;}` - [Test development mode using REPL](./cli.md#--repl). When reading the tests, it checks that only one test is running in one browser. | |||
* **runnableOpts** (optional): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new option which gives me ability to save test locations in file (line
and column
)
docs/programmatic-api.md
Outdated
@@ -317,6 +320,8 @@ TestCollection API: | |||
|
|||
* `eachRootSuite((root, browserId) => ...)` - iterates over all root suites in collection which have some tests. | |||
|
|||
* `format(formatterType)` - formats the tests in one of the available formatting types (`list` or `tree`). You can read more about the available formatting types [here](./cli.md#--formattername). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User can format test not only via cli command but also using testCollection.format
method
const allTestsById = new Map<string, FormatterListTest>(); | ||
|
||
testCollection.eachTest((test, browserId) => { | ||
if ((test as TestDisabled).disabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should do nothing with disabled tests (for example for passive browsers)
} | ||
|
||
if (allTestsById.has(test.id)) { | ||
const foundTest = allTestsById.get(test.id)!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the same test in different browsers, I specify only the field browserIds
. In order not to store too much of the same data (except for the browser name)
const treeTest = createTreeTest(test, browserId); | ||
allTestsById.set(treeTest.id, treeTest); | ||
|
||
collectSuites(test.parent!, treeTest, allSuitesById); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here, in order to create the right tree, I move from the tests (which can be disabled) up the parent suites.
const treeTest = allTestsById.get(test.id)!; | ||
|
||
if (!treeTest.browserIds.includes(browserId)) { | ||
treeTest.browserIds.push(browserId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like for list tests I just collect all browser ids for the same test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great addition overall! 🔥
Looks good to me besides documentation bits. Didn't look at unit tests.
4087fd7
to
3d47d40
Compare
3d47d40
to
ec7a5e8
Compare
What is done
Implement ability to read tests using cli command
npx testplane list-tests
which support options like for run tests:and new options:
The formatter supports 2 values: list (default) and tree. When using
list
user get plain list of unique tests, example:The same data in
tree
formatter looks like:the important difference is that the
tree
formatter supportsline
andcolumn
fields. They can be used to find out exactly where the suite or test is declared in the file. It will be used in vscode extension.The same output is supported via API -
testCollection.format(<type>)