Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Tests #355

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,12 @@
],
"plugins": [
"syntax-dynamic-import"
]
],
"env": {
"test": {
"presets": [
["env", { "targets": { "node": "current" }}]
]
}
}
}
32 changes: 32 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: 2
jobs:
build:
docker:
- image: circleci/node:11.8-browsers
steps:
- checkout # special step to check out source code to working directory
- restore_cache: # special step to restore the dependency cache
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: install npm dependencies
command: npm install
- save_cache: # special step to save the dependency cache
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: starting a development server
command: npm run dev
background: true
- run:
name: waiting for server to be responsive (for e2e)
command: |
while ! nc -z localhost 8080; do
sleep 0.1 # wait for 1/10 of the second before check again
done
- run:
name: running unit tests
command: npm run test:unit
- run:
name: running end to end tests
command: npm run test:e2e
36 changes: 36 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = {
// we can actually use "@/components/item.vue" to access components in a simple way
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/src/$1",
// the 'create-api' is defined in webpack
"^create-api$": '<rootDir>/src/api/create-api-client.js',
},
// the file types we want jest to accept
moduleFileExtensions: [
"js",
"json",
// tell Jest to handle `*.vue` files
"vue"
],
// transformations we want jest to apply
transform: {
// process `*.vue` files with `vue-jest`
".*\\.(vue)$": "vue-jest",
// process js files with jest
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
// process assets with transform stub
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
},
// we will use this to create snapshot tests
snapshotSerializers: [
'jest-serializer-vue',
],
// used for jsdom to mimic a real browser with a real url
testURL: 'http://localhost/',
// we should collect coverage
collectCoverage: true,
// set a directory for coverage cache
coverageDirectory: '<rootDir>/__coverage__',
// set patterns to ignore for coverate (["/node_modules/"]) is the default value
coveragePathIgnorePatterns: ["/node_modules/"]
};
Loading