|
1 | 1 | # vue-cli-plugin-e2e-codeceptjs
|
2 | 2 |
|
3 |
| -> e2e-codeceptjs plugin for vue-cli |
| 3 | +*Hey, how about some end 2 end testing for your Vue apps?* π€ |
4 | 4 |
|
5 |
| -[TODO] |
| 5 | +*Let's do it together! Vue, me, [CodeceptJS](https://codecept.io) & [Puppeteer](https://pptr.dev).* π€ |
| 6 | + |
| 7 | +*Browser testing was never that simple. Just see it!* π |
| 8 | + |
| 9 | +```js |
| 10 | +I.amOnPage('/'); |
| 11 | +I.click('My Component Button'); |
| 12 | +I.see('My Component'); |
| 13 | +I.say('I am happy!'); |
| 14 | +// that's right, this is a valid test! |
| 15 | +``` |
| 16 | + |
| 17 | +## How to try it? |
| 18 | + |
| 19 | +``` |
| 20 | +npm i vue-cli-plugin-codeceptjs-puppeteer --save-dev |
| 21 | +``` |
| 22 | + |
| 23 | +This will install CodeceptJS, CodeceptUI & Puppeteer with Chrome browser. |
| 24 | + |
| 25 | +To add CodeceptJS to your project invoke installer: |
| 26 | + |
| 27 | +``` |
| 28 | +vue invoke vue-cli-plugin-codeceptjs-puppeteer --save-dev |
| 29 | +``` |
| 30 | + |
| 31 | +> Should we add a test component so you could see how to interact with elements in your tests? Agree, if you start with an empty project & you don't mind we update your App.js & main.js files to add a test component. |
| 32 | +
|
| 33 | +## Running Tests |
| 34 | + |
| 35 | +We added npm scripts: |
| 36 | + |
| 37 | +* `test:e2e` - will execute tests with browser opened. If you installed test component, and started a test server, running this command will show you a brower window passed test. |
| 38 | + * Use `--headless` option to run browser headlessly |
| 39 | + * Use `--serve` option to start a dev server before tests |
| 40 | + |
| 41 | + |
| 42 | +Examples: |
| 43 | + |
| 44 | +``` |
| 45 | +npm run test:e2e |
| 46 | +npm run test:e2e -- --headless |
| 47 | +npm run test:e2e -- --serve |
| 48 | +``` |
| 49 | + |
| 50 | +> This command is a wrapper for `codecept run --steps`. You can use the [Run arguments and options](https://codecept.io/commands#run) here. |
| 51 | +
|
| 52 | +* `test:e2e:parallel` - will execute tests headlessly in parallel processes (workers). By default runs tests in 2 workers. |
| 53 | + * Use an argument to set number of workers |
| 54 | + * Use `--serve` option to start dev server before running |
| 55 | + |
| 56 | +Examples: |
| 57 | + |
| 58 | +``` |
| 59 | +npm run test:e2e:parallel |
| 60 | +npm run test:e2e:parallel -- 3 |
| 61 | +npm run test:e2e:parallel -- 3 --serve |
| 62 | +``` |
| 63 | + |
| 64 | +> This command is a wrapper for `codecept run-workers 2`. You can use the [Run arguments and options](https://codecept.io/commands#run-workers) here. |
| 65 | +
|
| 66 | +* `test:e2e:open` - this opens interactive web test runner. So you could see, review & run your tests from a browser. |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | +``` |
| 71 | +npm run test:e2e:open |
| 72 | +``` |
| 73 | + |
| 74 | +## Directory Structure |
| 75 | + |
| 76 | +Generator has created these files: |
| 77 | + |
| 78 | +```js |
| 79 | +codecept.conf.js π codeceptjs config |
| 80 | +jsconfig.json π enabling type definitons |
| 81 | +tests |
| 82 | +βββ e2e |
| 83 | +βΒ Β βββ app_test.js π demo test, edit it! |
| 84 | +βΒ Β βββ output π temp directory for screenshots, reports, etc |
| 85 | +βΒ Β βββ support |
| 86 | +βΒ Β βββ steps_file.js π common steps |
| 87 | +βββ steps.d.ts π type definitions |
| 88 | +``` |
| 89 | + |
| 90 | +If you agreed to create a demo component, you will also see `TestMe` component in `src/components` folder. |
| 91 | + |
| 92 | +## How to write tests? |
| 93 | + |
| 94 | +* Open `tests/e2e/app_js` and see the demo test |
| 95 | +* Execute a test & use interactive pause to see how CodeceptJS works |
| 96 | +* [Learn CodeceptJS basics](https://codecept.io/basics) |
| 97 | +* [Learn how to write CodeceptJS tests with Puppeteer](https://codecept.io/puppeteer) |
| 98 | +* [See full reference for CodeceptJS Puppeteer Helper](https://codecept.io/helpers/Puppeteer) |
| 99 | +* Ask your questions in [Slack](http://bit.ly/chat-codeceptjs) & [Forum](https://codecept.discourse.group/) |
| 100 | + |
| 101 | +## Enjoy testing! |
| 102 | + |
| 103 | +Testing is simple & fun, enjoy it! |
| 104 | + |
| 105 | +WIth β€ [CodeceptJS Team](https://codecept.io) |
0 commit comments