{"id":25179559,"url":"https://github.com/21hook/vue-test-utils-jest","last_synced_at":"2026-02-23T23:01:51.392Z","repository":{"id":144074196,"uuid":"135871703","full_name":"21hook/vue-test-utils-jest","owner":"21hook","description":"A Vue testing example using Jest","archived":false,"fork":false,"pushed_at":"2018-06-03T05:40:48.000Z","size":142,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T15:38:42.430Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Vue","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/21hook.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-03T03:53:57.000Z","updated_at":"2018-06-03T05:40:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"1d6038f1-90da-4328-9903-0fa6221cf17a","html_url":"https://github.com/21hook/vue-test-utils-jest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/21hook%2Fvue-test-utils-jest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/21hook%2Fvue-test-utils-jest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/21hook%2Fvue-test-utils-jest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/21hook%2Fvue-test-utils-jest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/21hook","download_url":"https://codeload.github.com/21hook/vue-test-utils-jest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247117762,"owners_count":20886439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-09T15:37:01.229Z","updated_at":"2025-10-31T03:35:51.674Z","avatar_url":"https://github.com/21hook.png","language":"Vue","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vue-test-utils-jest-example\n\n\u003e Example project using Jest + vue-test-utils together\n\nThis is based on the `vue-cli` `webpack-simple` template. Test-specific changes include:\n\n### Additional Dependencies\n\n- `vue-test-utils`\n- `jest`\n- `babel-jest` (for ES2015+ features in tests)\n- `vue-jest` (for handling `*.vue` files in tests)\n- `jest-serializer-vue` (for snapshot tests)\n\n### Additional Configuration\n\n#### `package.json`\n\nThe following configurations are recommended for Jest:\n\n``` js\n{\n  \"jest\": {\n    \"moduleFileExtensions\": [\n      \"js\",\n      \"json\",\n      // tell Jest to handle *.vue files\n      \"vue\"\n    ],\n    \"transform\": {\n      // process js with babel-jest\n      \"^.+\\\\.js$\": \"\u003crootDir\u003e/node_modules/babel-jest\",\n      // process *.vue files with vue-jest\n      \".*\\\\.(vue)$\": \"\u003crootDir\u003e/node_modules/vue-jest\"\n    },\n    // support the same @ -\u003e src alias mapping in source code\n    \"moduleNameMapper\": {\n      \"^@/(.*)$\": \"\u003crootDir\u003e/src/$1\"\n    },\n    // serializer for snapshots\n    \"snapshotSerializers\": [\n      \"\u003crootDir\u003e/node_modules/jest-serializer-vue\"\n    ]\n  }\n}\n```\n\n#### `.babelrc`\n\nOur default Babel config disables ES modules transpilation because webpack already knows how to handle ES modules. However, we do need to enable it for our tests because Jest tests are run directly in Node.\n\nAlso, if our tests are run in a relatively newer version of Node, most of the ES features are already supported - we can tell `babel-preset-env` to target the Node version we are using. This skips transpiling unnecessary features and makes our tests boot faster.\n\nTo apply these options only for tests, we need to add a separate config under `env.test` (this will be automatically picked up by `babel-jest`):\n\n``` json\n{\n  \"presets\": [\n    [\"env\", { \"modules\": false }]\n  ],\n  \"env\": {\n    \"test\": {\n      \"presets\": [\n        [\"env\", { \"targets\": { \"node\": 8 }}]\n      ]\n    }\n  }\n}\n```\n\n### Build Commands\n\n``` bash\n# install dependencies\nnpm install\n\n# serve with hot reload at localhost:8080\nnpm run dev\n\n# build for production with minification\nnpm run build\n\n# run tests\nnpm test\n```\n\nFor detailed explanation on how things work, consult the [docs for vue-test-utils](https://vue-test-utils.vuejs.org/guides/#testing-single-file-components-with-jest).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F21hook%2Fvue-test-utils-jest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F21hook%2Fvue-test-utils-jest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F21hook%2Fvue-test-utils-jest/lists"}