GitXplorerGitXplorer
h

vite-test-example

public
6 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
01070138b9f4308463c8df46a38f6768383d5562

fix: windows compatibility

hhaoqunjiang committed 4 years ago
Verified
5712fdfab131e13a94753b0ce3e34ecaba5686eb

docs: about directory structure

hhaoqunjiang committed 4 years ago
Verified
b1c54061c1c34aaade9e9c32519c384262b813bf

chore: we don't need `testRunnerHtml` for `@vue/test-utils`

hhaoqunjiang committed 4 years ago
Verified
cc447739d348c5cecca7f8f9344148d53b5c7e62

refactor: use aliased path in the spec file to illustrate its capabilities

hhaoqunjiang committed 4 years ago
Verified
ad80553d887e501da92cd9e1417ba98517523b59

refactor: setup unit test with @web/test-runner so that we can have coverage reports

hhaoqunjiang committed 4 years ago
Verified
405a660695f0cb545d369accae0a80d24a31bf95

refactor: let's use .mjs to go full ESM

hhaoqunjiang committed 4 years ago

README

The README file for this repository.

vite-test-example

The directory structure and commands for tests are the same as the projects created by @vue/cli.

E2E Testing

This repository uses Cypress as an example to illustrate how to setup end-to-end tests with Vite.

To try it out, run:

yarn test:e2e

Running end-to-end tests with Vite is no different from other bundlers:

  • Bundle the app for production;
  • Start a static HTTP server;
  • Run the command from the test framework.

Vite provides a built-in static HTTP server to preview the build results. We can start it by running vite preview (or yarn serve). The default URL of this preview server is http://localhost:5000/. So we also set the baseUrl option in cypress.json to this URL.

vite preview serves the dist folder's content, which results from the vite build command. So we add a preserve hook to the script section of package.json to run this command. Therefore, whenever you run npm run serve, vite build will be executed first.

Unit Testing

yarn test:unit

This repository uses @web/test-runner and vite-web-test-runner-plugin to execute unit tests.

The test framework is Mocha and the assertion library is Chai.

TODOs

  • TypeScript example
  • CI setup