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

Testing in isolation #57

Open
nhedger opened this issue Aug 2, 2024 · 4 comments
Open

Testing in isolation #57

nhedger opened this issue Aug 2, 2024 · 4 comments

Comments

@nhedger
Copy link

nhedger commented Aug 2, 2024

Feature request

It would be nice to be able to run all tests in isolation.

Ideally, every test would receive a fresh VS Code instance, free of any previous state.

Use case

When running tests that affect the state of VS Code, it can be cumbersome to ensure that some actions have a direct link to a desired state. For example, if you want to test whether opening files of a given type activates the extension, if you run these tests one after the other, the first test will trigger the activation, and subsequent tests will succeed because the previous test has activated the extension.

@connor4312
Copy link
Member

You can do that by creating a .vscode-test file that has a configuration that runs each individual test. However, this is going to be quite slow, especially for large suites, and is better replaced by tracking state changes made in tests and resetting them in lifecycle teardown points.

@nhedger
Copy link
Author

nhedger commented Aug 2, 2024

Hey @connor4312,

I've been doing that as a workaround; setting it up is a real pain.

Tracking changes and resetting would definitely work in some cases, but as far as I know, we cannot programmatically deactivate an extension, so that wouldn't work in the case outlined in my first message.

As a side note, mocha's afterEach and beforeEach don't seem to be available in the test environment as they seem to be only available when executing mocha on the CLI, which makes this even harder.

Anyway, just thought I'd leave this here as food for thought!

@connor4312
Copy link
Member

afterEach/beforeEach are definitely available, but note that in the default tdd mocha UI they're called setup and teardown https://mochajs.org/#interfaces

@nhedger
Copy link
Author

nhedger commented Aug 2, 2024

Ah indeed, thanks for pointing it out!

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

2 participants