小编use*_*511的帖子

如何用玩笑测试nuxt?

我只是在开玩笑地学习 Nuxt。我的test.vue。刚刚从https://nuxtjs.org/docs/2.x/features/data-fetching复制

<template>
  <div>
    <h1 class="page-title">Mountains</h1>
    <p v-if="$fetchState.pending">Fetching mountains...</p>
    <p v-else-if="$fetchState.error">An error occurred :(</p>
    <div v-else>
      <h1>Nuxt Mountains</h1>
      <ul>
        <li v-for="mountain of mountains">{{ mountain.title }}</li>
      </ul>
      <button @click="$fetch">Refresh</button>
    </div>
  </div>
</template>
<script>
export default {
  data () {
    return {
      mountains: [],
    }
  },
  async fetch () {
    this.products = await fetch(
       'https://api.nuxtjs.dev/mountains'
    ).then(res => res.json())
  }
}
</script>
Run Code Online (Sandbox Code Playgroud)

我的 test.spec.js

import { mount } from '@vue/test-utils'
import Test from '@/components/test.vue'

describe('Test', () => {
  test('is a Vue …
Run Code Online (Sandbox Code Playgroud)

vue.js jestjs nuxt.js

2
推荐指数
1
解决办法
1449
查看次数

标签 统计

jestjs ×1

nuxt.js ×1

vue.js ×1