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

Need for non-UI end-to-end testing #2919

Closed
simark opened this issue Sep 19, 2018 · 6 comments
Closed

Need for non-UI end-to-end testing #2919

simark opened this issue Sep 19, 2018 · 6 comments
Labels
test issues related to unit and api tests

Comments

@simark
Copy link
Contributor

simark commented Sep 19, 2018

I recently wanted to make an end-to-end test involving Theia and clangd, to verify that some actions in the frontend (changing build configuration) worked correctly with clangd and that the system as a whole gave good results.

The only way right now is to do a UI test, where you simulate clicks in a Theia application. However, there is nothing in this test that inherently needs to be UI-driven. We only need some non-UI components of the frontend, a backend, and clangd.

I think it would be nice to be able to run tests where we instantiate some non-UI components of the frontend (including the bits necessary to connect to a backend) and drive the test from a standard mocha test file.

@svenefftinge
Copy link
Contributor

Can't you just try to make it work and then we see how we can extract general parts if it's worth it?

@simark
Copy link
Contributor Author

simark commented Sep 25, 2018

I tried a little bit and hit some road bumps, so I wanted to see if any of you saw any reason why this would be a bad idea, before going further.

@amiramw
Copy link
Member

amiramw commented Jan 15, 2019

I did some integration non UI testings for the fontend modules of theia extensions (no backend modules).
In order to allow tests to access them I had to expose inversify internal dictionary by injecting the following code next to the initialization of the inversify container:

window.TheiaApiTest = {
    getServiceBindingByClass: (s) => {
        let filteredEntries = Array.from(container._bindingDictionary.getMap().entries())
            .filter(arr => arr[0].toString().startsWith("function " + s));
        let bindingPair = filteredEntries && filteredEntries[0];
        return bindingPair && bindingPair[1] && bindingPair[1][0] && bindingPair[1][0].cache;
    }
};

For my initial use case this method was enough but I guess that in time there will be more of them.

I used jest-puppeteer to execute code in the browser context in my tests. So the test code looks somewhat like this:

let value = await page.waitForFunction(() => {
      return TheiaApiTest.getServiceBindingByClass("MyContribution")
        .doSomething();
    });
expect(value).toEqual("hello");

If this mechanism is desired inside theia I can create a PR.

@vince-fugnitto vince-fugnitto added the test issues related to unit and api tests label Oct 29, 2019
@paul-marechal
Copy link
Member

@amiramw is it similar to #5654?

@amiramw
Copy link
Member

amiramw commented Oct 29, 2019

As far as I understand yes. But I didn't get into it yet.

@vince-fugnitto
Copy link
Member

Closed in #6852 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test issues related to unit and api tests
Projects
None yet
Development

No branches or pull requests

5 participants