GitXplorerGitXplorer
v

vue-test-utils-typescript-example

public
61 stars
31 forks
3 issues

Commits

List of commits on branch master.
Unverified
6df01bd762414001162a62ced746b2180e3b0070

fix: add jest types

eeddyerburgh committed 6 years ago
Unverified
c0ea7ec096db3af934e6255451a179955263da1d

docs: add README

eeddyerburgh committed 6 years ago
Unverified
63932cb2e98baff012166b3ef905bf0cb32f0dfb

init

eeddyerburgh committed 6 years ago

README

The README file for this repository.

vue-test-utils-typescript-example

Example project using TypeScript, Jest + vue-test-utils together

This is based on the vue-cli 3 basic template. Test-specific changes include:

Additional Dependencies

  • vue-test-utils
  • jest
  • ts-jest (for TypeScript compilation in tests)
  • vue-jest (for handling *.vue files in tests)
  • jest-serializer-vue (for snapshot tests)

Additional Configuration

package.json

The following configurations are recommended for Jest:

{
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts",
      // tell Jest to handle *.vue files
      "vue"
    ],
    "transform": {
      // process TypeScript files
      "^.+\\.ts$": "ts-jest",
      // process *.vue files with vue-jest
      ".*\\.(vue)$": "vue-jest"
    },
    // support the same @ -> src alias mapping in source code
    "moduleNameMapper": {
      "^@/(.*)$": "<rootDir>/src/$1"
    },
    // serializer for snapshots
    "snapshotSerializers": [
      "jest-serializer-vue"
    ]
  }
}

Build Commands

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

# run tests
npm test