You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document test API in positron-r's CONTRIBUTING.md file (#9210)
Follow up to #8816
<!-- Thank you for submitting a pull request.
If this is your first pull request you can find information about
contributing here:
* https://github.com/posit-dev/positron/blob/main/CONTRIBUTING.md
We recommend synchronizing your branch with the latest changes in the
main branch by either pulling or rebasing.
-->
<!--
Describe briefly what problem this pull request resolves, or what
new feature it introduces. Include screenshots of any new or altered
UI. Link to any GitHub issues but avoid "magic" keywords that will
automatically close the issue. If there are any details about your
approach that are unintuitive or you want to draw attention to, please
describe them here.
-->
### Release Notes
<!--
Optionally, replace `N/A` with text to be included in the next release
notes.
The `N/A` bullets are ignored. If you refer to one or more Positron
issues,
these issues are used to collect information about the feature or
bugfix, such
as the relevant language pack as determined by Github labels of type
`lang: `.
The note will automatically be tagged with the language.
These notes are typically filled by the Positron team. If you are an
external
contributor, you may ignore this section.
-->
#### New Features
- N/A
#### Bug Fixes
- N/A
### QA Notes
<!--
Positron team members: please add relevant e2e test tags, so the tests
can be
run when you open this pull request.
- Instructions:
https://github.com/posit-dev/positron/blob/main/test/e2e/README.md#pull-requests-and-test-tags
- Available tags:
https://github.com/posit-dev/positron/blob/main/test/e2e/infra/test-runner/test-tags.ts
-->
<!--
Add additional information for QA on how to validate the change,
paying special attention to the level of risk, adjacent areas that
could be affected by the change, and any important contextual
information not present in the linked issues.
-->
Copy file name to clipboardExpand all lines: extensions/positron-r/CONTRIBUTING.md
+37Lines changed: 37 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,43 @@ npm run test-extension -- -l positron-r
9
9
```
10
10
11
11
12
+
## API
13
+
14
+
Besides Mocha (see below), we provide a "Test Kit" with:
15
+
16
+
- Helpers to manage synchronisation of effects.
17
+
18
+
- It's not always possible to deterministically wait for an effect. For instance, the timing of testing the effect of a notification to open an editor via RStudio API can be tricky. The RStudio API call is like a fire-and-forget event and you're only testing that an editor will _eventually_ be opened on the frontend side. For these cases you can use `pollForSuccess()`, which will retry an assertion until it passes (stops throwing assertion errors).
19
+
20
+
-`assertSelectedEditor()` is a wrapper around `pollForSuccess()` that checks an editor is getting selected.
21
+
22
+
-`retryRm()` to try deleting a file or folder until success. Useful on Windows as you might have to wait until the file is effectively released by some component (e.g. a text document you just closed).
23
+
24
+
- Helpers to deal with temporary resources like R sessions and temporary files, and cleaning up once a test has run.
25
+
26
+
-`startR()` creates and returns an `RSession`, along with a disposable to delete it at the end of a test or suite. Since there is an overhead to starting and cleaning a session, we recommend having one session per file, started in `suiteSetup()` and cleaned up in `suiteTeardown()`.
27
+
28
+
-`openTextDocument()` that returns a document and a disposable to close it. See also `closeAllEditors()` to ensure all editors you might have opened are closed at the end of a test.
29
+
30
+
-`makeTempDir()` returns a temporary directory path and a disposable to clean it up.
31
+
32
+
- The lifecycle of temporary resources is managed with the disposable pattern and we provide tools to help deal with disposables:
33
+
34
+
-`toDisposable()` to create a disposable from a closure.
35
+
36
+
-`disposeAll()` to dispose of an array of disposables.
37
+
38
+
-`withDisposables()` calls a closure with an array of disposables that are automatically disposed on exit, even in case of error.
39
+
40
+
- Helpers to manage the VS Code UI.
41
+
42
+
The test kit can be imported in your test files with:
43
+
44
+
```ts
45
+
import*astestKitfrom'./kit';
46
+
```
47
+
48
+
12
49
## Infrastructure
13
50
14
51
The extension tests are located in `src/test/`. They are executed via:
0 commit comments