Closed sobolevn closed 6 years ago
Limitations that really bother me:
docker
support, it does not support alpine
, it also misses any node-version
support. So we will have to sync node
version by ourself One more example: https://github.com/chymz/nuxt-template/tree/master/template/cypress
Ok, here's my thoughts about this problem:
Framework | Engine | Assertions | Different browsers | Speed | Docker | Linting | User interactions |
---|---|---|---|---|---|---|---|
Cypress | Tests are injected into the web page | Custom | Some | Bearable | Slim | Custom eslint config | Yes |
JSDom | Native server-side JS | Any | No | Best | Any, including Alpine | Not needed | No |
Nightwatch | Selenium/WebDriver | Custom | Yes | Slow | Container Hell | Not available | Yes |
Puppeteer | Headless Chrome | Any | No | Bearable | Alpine | Not available | Yes |
TestCafe | Tests are injected into the web page | Custom | Yes | Bearable | Alpine | Custom eslint config | Yes |
Features:
Resources used in this research:
Cypress: https://github.com/chrisvfritz/vue-enterprise-boilerplate/tree/master/tests/e2e TestCafe: https://github.com/egoist/vuepack/blob/master/template/test/e2e/index.js Puppeteer: https://github.com/studbits/nuxt-jest-puppeteer
https://github.com/DevExpress/testcafe#creating-the-test
Sample:
import { Selector } from 'testcafe'; // first import testcafe selectors
fixture `Getting Started`// declare the fixture
.page `https://devexpress.github.io/testcafe/example`; // specify the start page
//then create a test and place your code there
test('My first test', async t => {
await t
.typeText('#developer-name', 'John Smith')
.click('#submit-button')
// Use the assertion to check if the actual header text is equal to the expected one
.expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');
});
Running: npx testcafe chrome testcafe.js
Result:
» npx testcafe chrome testcafe.js
npx: installed 285 in 21.6s
Running tests in:
- Chrome 63.0.3239 / Mac OS X 10.11.6
Getting Started
✓ My first test
1 passed (3s)
flow
support: https://github.com/DevExpress/testcafe/blob/master/docs/articles/documentation/recipes/finding-code-issues-with-flow-type-checker.mdvscode
debug: https://github.com/DevExpress/testcafe/blob/master/docs/articles/documentation/recipes/debugging-with-visual-studio-code.mdvue
selector: https://github.com/DevExpress/testcafe-vue-selectorsnuxt
selector: https://github.com/kartojal/testcafe-nuxt-selectorsbrowserstack
integration: https://github.com/DevExpress/testcafe-browser-provider-browserstackSample:
import VueSelector from 'testcafe-nuxt-selectors'
fixture('Getting Started')
.page('http://localhost:3000')
.beforeEach(async () => await VueSelector())
test('My first test', async (t) => {
const root = VueSelector()
const rootVue = await root.getVue()
await t.expect(root.exists).ok()
await t.expect(rootVue.state.layoutName).eql('default')
})
Output:
» ./node_modules/.bin/testcafe chrome --app "yarn dev" --app-init-delay 10000 testcafe.js
Running tests in:
- Chrome 63.0.3239 / Mac OS X 10.11.6
Getting Started
✓ My first test
1 passed (2s)
return (instance.$options._componentTag || instance.$options.__file || '')
I have implemented this kind of pipeline: nuxt build && ./node_modules/.bin/testcafe chrome --app "yarn start" --app-init-delay 10000 testcafe.js
This way it works. Mostly.
@sobolevn why not consider webdriver.io?
@christian-bromann thanks for advice! I did not know that this product exists.
I try to remove selenium
from our toolchain. The main reason for it is speed and setup complexity.
We run everything inside docker-compose
for development and testing. And I need a simple solution to just work in this setup. When we had nightwatch
with webdriver
bindings it was really hard to manage all the test containers with jvm
and stuff.
Speed. I need to run all tests before merging a PR. So, it should not take long to start and execute tests. My previous experience with selenium
was too slow.
Can you please correct me if I am wrong about these two point? Thanks!
You can definitely get a decent speed when setting up the driver properly. By running Chrome headless with Chromedriver (instead of the Selenium standalone server) your test should be quick. A quick google search gave me this project which seems to exactly do that: https://github.com/kaitoy/webdriverio-chrome
Just to contribute with my grain of sand, you can run Testcafe with concurrency enabled, with chrome and/or firefox in headless mode. For example you can divide 100 tests into 2 concurrent headless chrome browsers, doing each instance 50 tests. In that way it improves the testing speed. Ex:
testcafe chrome:headless -c 2 test/e2e/*spec*
@kartojal thanks! Currently testing it out.
This looks promising: https://gitlab.com/cypress-io/cypress-example-docker-gitlab
Working example: https://github.com/chrisvfritz/vue-enterprise-boilerplate/tree/master/tests/e2e Docs: https://github.com/chrisvfritz/vue-enterprise-boilerplate/blob/master/docs/tests.md#end-to-end-tests-with-cypress