schlunsen / nuxt-leaflet

Nuxt module for leafletjs - https://schlunsen.github.io/nuxt-leaflet/
MIT License
200 stars 29 forks source link

Write tests #1

Open schlunsen opened 6 years ago

danieldanielecki commented 3 years ago

+1, some kind of unit tests would be needed. In addition to that, the <client-only> breaks all unit tests, and it's not possible to register the component, as the other ones in unit tests, such as l-map, via Vue.component("l-map", LMap); etc.

In addition to that,

created(): void {
  this.$nextTick(() => {
    this.myMap = this.$refs.map.mapObject; // "this.$refs.map.mapObject" is a Leaflet object. Read more: https://vue2- 
 leaflet.netlify.app/faq/#how-can-i-access-the-leaflet-map-object
    this.myMap.setView([lat, lng], 12);
    ...
  }
}

breaks unit tests with the error console.error TypeError: Cannot read property 'setView' of undefined

Last, but not least, might be related to this. All the time after implementing nuxt-leaflet, I can see in my terminal [Vue warn]: Error in nextTick: "TypeError: Cannot read property 'mapObject' of undefined" while running the app locally npm run dev.