Skip to content
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

Unit and integration tests #990

Open
renkun-ken opened this issue Feb 13, 2022 · 13 comments
Open

Unit and integration tests #990

renkun-ken opened this issue Feb 13, 2022 · 13 comments

Comments

@renkun-ken
Copy link
Member

Currently, we only have very limited testing of the features of vscode-R.

We might need to put a demo R package and R script folder in the repo and run tests with opening the folder as a workspace folder and test at least the following features:

  • Language server startup
  • Session watcher
  • R markdown commands
@gowerc
Copy link
Contributor

gowerc commented Feb 13, 2022

Just want to say that I think given the size of this project now that it would be valuable to add more tests mostly for the obvious reasons

  • Tests act as proof that someones contribution is working as expected
  • Tests prevent regressions and alert us to breakages in the extension

That being said testing in vscode does not appear to be straight forward. One issue in particular seems to be that you can't switch between workspaces (which I figured would be critical for us testing different setups/configurations).

Having said that it seems to be easy enough to launch the tests on a single specific directory though by editing the launch.json file to specify the target directory:

    {
      "name": "Extension Tests",
      "type": "extensionHost",
      "request": "launch",
      "runtimeExecutable": "${execPath}",
      "args": [
        "${workspaceFolder}/test/sample-project",   // <--------------------------
        "--extensionDevelopmentPath=${workspaceFolder}",
        "--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
      ],
      "outFiles": [
        "${workspaceFolder}/out/test/**/*.js"
      ],
      "preLaunchTask": "npm: pretest"
    }

Potentially one idea could be to have multiple test scripts each loading a separate directory and then placing conditions on test suites to only fire if a certain directory is active ?

Likewise I'm happy to help writing some of these tests as it will be a good opportunity to learn, that being said I will need some help / pointers as I've really been struggling to get my head around what is even possible with the vscode api sorry :(

@github-actions
Copy link

This issue is stale because it has been open for 365 days with no activity.

@github-actions github-actions bot added the stale label Feb 14, 2023
@ElianHugh
Copy link
Collaborator

unstale

@renkun-ken
Copy link
Member Author

renkun-ken commented Feb 14, 2023

Currently, the testing no longer works in all recent PRs (#1290, #1296) where test fails with TypeError: util.config is not a function. No clue how to resolve this. Tried for a while but nothing worked.

@ElianHugh
Copy link
Collaborator

just spitballing - is it possible that there's a namespace collision between util.ts and the node util module?

@renkun-ken
Copy link
Member Author

Tried renaming util to utils but no luck.

@ElianHugh
Copy link
Collaborator

ElianHugh commented Feb 14, 2023

It's interesting that it's occurring just with knit.ts... I'll try to play around with this and see if something works

Edit:

Some interesting links:

Could have something to do with the headless tests? I can't replicate the issue locally

@renkun-ken
Copy link
Member Author

I can't replicate it, either. Would be nice if we could make it work somehow again.

@ElianHugh
Copy link
Collaborator

ElianHugh commented Feb 15, 2023

I believe I have a fix! Will PR shortly

Edit: See #1302

@github-actions github-actions bot removed the stale label Feb 15, 2023
@ElianHugh
Copy link
Collaborator

An issue I've found when approaching unit testing rmd knitting is that I have to mock the vscode API (e.g. activeTextEditor). There doesn't seem to be a straightforward way of mocking?

@ElianHugh
Copy link
Collaborator

we can probably leverage testthat or similar packages within child processes for consistency?

Copy link

This issue is stale because it has been open for 365 days with no activity.

@github-actions github-actions bot added the stale label Feb 18, 2024
@ElianHugh
Copy link
Collaborator

unstale

@github-actions github-actions bot removed the stale label Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants