All Projects → kjugi → meeting-app-unit-tests-playground

kjugi / meeting-app-unit-tests-playground

Licence: MIT license
Unit tests patterns when using JEST and Vue2 (vue-test-utils)

Programming Languages

javascript
184084 projects - #8 most used programming language
Vue
7211 projects
HTML
75241 projects

Projects that are alternatives of or similar to meeting-app-unit-tests-playground

Bunit
A testing library for Blazor Components. You can easily define components under test in C# or Razor syntax and verify outcome using semantic HTML diffing/comparison logic. You can easily interact with and inspect components, trigger event handlers, provide cascading values, inject services, mock IJSRuntime, and perform snapshot testing.
Stars: ✭ 415 (+1876.19%)
Mutual labels:  unit-testing, snapshot-testing
json-snapshot.github.io
Snapshot Testing for Java
Stars: ✭ 28 (+33.33%)
Mutual labels:  unit-testing, snapshot-testing
Enzyme To Json
Snapshot test your Enzyme wrappers
Stars: ✭ 954 (+4442.86%)
Mutual labels:  unit-testing, snapshot-testing
MockitoIn28Minutes
Learn Mockito from In28Minutes
Stars: ✭ 95 (+352.38%)
Mutual labels:  unit-testing, mocking-frameworks
bUnit
bUnit is a testing library for Blazor components that make tests look, feel, and runs like regular unit tests. bUnit makes it easy to render and control a component under test’s life-cycle, pass parameter and inject services into it, trigger event handlers, and verify the rendered markup from the component using a built-in semantic HTML comparer.
Stars: ✭ 857 (+3980.95%)
Mutual labels:  unit-testing, snapshot-testing
jest-puppe-shots
A Jest plugin for creating screenshots of React components with a little help of Puppeteer
Stars: ✭ 86 (+309.52%)
Mutual labels:  unit-testing
react-native-ecommerce
E-commerce mobile application developed using React Native 👔 🎩
Stars: ✭ 60 (+185.71%)
Mutual labels:  unit-testing
quasar-testing
Testing Harness App Extensions for the Quasar Framework 1.0+
Stars: ✭ 142 (+576.19%)
Mutual labels:  unit-testing
toUUID
Simple integer to UUID generator for unit and integration tests written in Java or Kotlin
Stars: ✭ 12 (-42.86%)
Mutual labels:  unit-testing
WoWUnit
A unit testing framework for World of Warcraft
Stars: ✭ 20 (-4.76%)
Mutual labels:  unit-testing
FluentAssertions.Web
FluentAssertions for HTTP APIs
Stars: ✭ 71 (+238.1%)
Mutual labels:  unit-testing
whats-new-in-swift-5-2
An Xcode playground that demonstrates the new features introduced in Swift 5.2.
Stars: ✭ 94 (+347.62%)
Mutual labels:  playground
logunit
A Java library for unit-testing logging.
Stars: ✭ 40 (+90.48%)
Mutual labels:  unit-testing
book-fullstack-react-with-typescript
Working through the code samples from Fullstack React with Typescript by Maksim Ivanov and Alex Bespoyasov
Stars: ✭ 52 (+147.62%)
Mutual labels:  unit-testing
concise
✅ Concise is test framework for using plain English and minimal code, built on PHPUnit.
Stars: ✭ 47 (+123.81%)
Mutual labels:  unit-testing
PathView
Simulate the running route of each player on the playground, and can be timed with a stopwatch
Stars: ✭ 5 (-76.19%)
Mutual labels:  playground
minibed
It's a mini editable, customizable playground for web
Stars: ✭ 41 (+95.24%)
Mutual labels:  playground
emacs-python-pytest
run pytest inside emacs
Stars: ✭ 105 (+400%)
Mutual labels:  unit-testing
edge-mock
Tools for testing and developing CloudFlare worker apps.
Stars: ✭ 49 (+133.33%)
Mutual labels:  unit-testing
learning-unit-testing-for-k8s-operator
学习如何为 Kubernetes Operators 进行单元测试 Learning How to Write Unit Tests for Kubernetes Operators
Stars: ✭ 51 (+142.86%)
Mutual labels:  unit-testing

unit-tests-playground

Requirements

$ node -v
v12.16

Where we have code - project structure

api/ - directory with our backend and 2 simple endpoints for app

done/ - directory with ready to run app and all unit tests as an examples

practices/ - directory with ready to run add but without any test cases finished

Start app locally

Each directory has own package.json file which contains informations about scripts. Hoever here is a list to start API from api/ directory and app from done/ directory:

First CLI tab:

cd api && yarn && yarn start

Second CLI tab:

cd done && yarn && yarn serve

After that API should be available on http://localhost:5679 And app should be available on http://localhost:8080

Run tests

From done/ directory

yarn test:unit

Same command is in /practices directory

To run single test file from done/ directory:

jest path/to/test/file.spec.js

Real example:

jest tests/unit/Home.spec.js

Overview of 2 routes booking app:

  1. Homepage view with all booked meetings
  2. Simple API in other directory on express
  3. Second view to book meeting:
    • input for email or select with list of people to meet with toggle checkbox
    • selecting date of meeting
    • save button
  4. Saving button adds meeting after backend response to booked meetings view

Unit tests to write:

  1. Message component
    • renders prop title when passed
    • emit event when isMessageShowed updates
    • default component matches snapshot
  2. Checkbox component
    • emit events when change checked value
    • default component matches snapshot
  3. Home view
    • meeting list contains elements from store
    • render empty list message when don't have items
  4. Add Meeting view
    • default form is rendered
    • has loading class when form is blocked
    • predefined addreses are available
    • predefined select change value to selected option
    • predefined checkbox toggle fields and clear values
    • can set custom meeting day in form
    • min attribute in input date has today date
    • error is showed when form is invalid
    • button can be disable or enabled
    • can add meeting to store
    • message is showed after button click and hide on @hideMessage event
  5. Actions
    • doReservation commits to mutation
    • exampleApiAction makes commit based on API response
  6. Mutations
    • addMeeting push item to state.meetingList
  7. Getters
    • getTodayMeetings returns meetings from today

Covered topics and good practices in this repo:

  • Basic tests
  • Mocking functions (axios)
  • Testing mocked API responses
  • Mocking vuex store
  • Timer mocks
  • Factory functions
  • Emitt events testing
  • async testing syntax
  • Testing vuex actions, mutations and getters
  • Both side component testing
  • Snapshot testing
  • Acceptance testing and snapthot-diff checking
  • Using data-testid in components and tests
  • Using husky to run Githooks for unit tests

Extra topic, not recommended in big stores:

  • Testing Vuex store instance

What about Vuex modules?

It's the same approach as importing actions from single module Vuex store. You are just importing actions from store module and i.e. testing in separate file for each store module

storeModuleA.js
storeModuleB.js
storeModuleAActions.spec.js
storeModuleAGetters.spec.js
storeModuleBActions.spec.js
...

Found a bug or repo needs update? - contribute

If you found some problem with API or meeting app please create an issue or PR with changes

Have a problem?

Open an issue or search in existing ones

License

Over MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].