Closed fvictorio closed 6 years ago
@igorbarinov Some thoughts about this:
For completeness, I should mention that another approach is possible: this article (the only thing I found about e2e tests for dapps) injects a custom web3 instance during the tests and uses that to interact with the dapp. I'm not sure if this approach allows, for example, to simulate a user rejecting a transaction.
tl;dr: I think my approach, while somewhat limiting, is good enough for writing some basic tests and save us some time doing them manually. Integrating them with a CI with a windowed environment is something that we should investigate.
How do you think we should proceed?
Do we really need a headless browser for testing the ICO wizard? With headless testing e2e script will work faster but how is it important ?
e2e script contains two parts:
Anyway time of e2e scrip execution too long and takes around 10 minutes. As a result there is no advantage to use Puppeteer.
I see two approaches to create e2e script.
Using Puppeteer:
Using Selenium:
Both approach can be integrated with Circle CI.
I have created end-to-end scrypt for the Token wizard .
https://www.npmjs.com/package/create-poa-crowdsale https://www.youtube.com/watch?v=fcmSzWso1_U
Scrypt performs:
@dennis00010011b
is it possible to add URL of Token Wizard to config, for example, to test local deployment before deploying to main link?
@vbaranov did you mean a kind of breakpoint? Good idea. I'll do it asap
@dennis00010011b Breakpoints are good to have too. But I meant that utility uses this link https://wizard.poa.network
now. But, for example, I need to test new patch for wizard locally before merging to the main link. I would like to change endpoint in the configuration file and start the utility for another link. Maybe, to add an endpoint to crowdsale.json
or to separate config file. If I am not wrong, with the current version of the utility, I need to change the link in many places to connect to wizard on another link.
Updated. Now startURL can be added in config.json Also , installation of MetaMask can be skipped
{
"startURL" : "https://wizard.poa.network/",
"installMetaMask":true
}
@dennis00010011b could we transfer the repo to poanetwork github org?
@igorbarinov Done https://github.com/poanetwork/e2e-test-token-wizard
@fvictorio @vbaranov I need your opinion about e2e scrypt. How we can use it ? How we can hook up scrypt to CI and launch it with each pull request? Which CI is better to use: Circle,Travis, anything else? Any thoughts?
@dennis00010011b
We use Travis CI for Token Wizard, which includes Mocha unit tests for Solidity contracts.
My suggestion is to provide binary for e2e utility: https://github.com/poanetwork/e2e-test-token-wizard/issues/6. Thus, we will be able to add launching of it to npm test
script of Token wizard. And, maybe, organize e2e tests with using of Mocha too to unify results of Solidity and e2e tests.
Ideally we would have a way to automatically run the e2e tests in the deploy previews that Netlify creates, but I don't know how to do that.
The next best thing is for Travis to:
Using ganache is optional, but it would mean faster executions. This is more doable, but, as Victor said, we would need to be able to add the e2e repo as a dependency, submodule or just moving the code to this repo.
I experimented a little with using Puppeteer to create an end-to-end test for the ICO Wizard. The result is here:
https://github.com/fvictorio/ico-wizard-e2e
Just cloning it, doing
npm install
andnpm start
should work. It will run a single test that creates a simple crowdsale. By default it uses the local node, so before running it you should go to theico-wizard
repository and executenpm run ganache
and (in another terminal)npm run deployRegistry
.Doing this kind of tests is hard because there is a browser extension involved. In fact, I couldn't find a single tutorial for doing e2e tests for dapps with metamask. But since we spend a lot of time manually testing that everything is working, this may be useful.
Let me know what you think.