小编And*_* C.的帖子

Jest 单元测试期间 Vue 路由器的注入失败

在具有 Composition API(和 Vue 3)的 .vue 文件中,设置路由器:

const router = useRouter()
Run Code Online (Sandbox Code Playgroud)

在玩笑测试中挂载 .vue 文件:

const wrapper = mount(Lookup)
Run Code Online (Sandbox Code Playgroud)

执行时,产生:

console.warn
    [Vue warn]: injection "Symbol([vue-router]: router)" not found.
      at <Anonymous ref="VTU_COMPONENT" >
      at <VTUROOT>
Run Code Online (Sandbox Code Playgroud)

模拟它会产生相同的输出:

useRouter().push = jest.fn()
Run Code Online (Sandbox Code Playgroud)

设置提供相同输出的结果:

import { useRouter } from 'vue-router'
...
const wrapper = mount(Lookup, {
  global: {
    plugins: [useRouter],
    provide: {
      router: {},
    },
  },
})
Run Code Online (Sandbox Code Playgroud)

vue.js jestjs vue-router

5
推荐指数
2
解决办法
3916
查看次数

(WP-CLI) 未创建 Wordpress-Tests_Lib 文件

我正在尝试在 Ubuntu 14.04 上进行 WordPress 插件测试,我正在设置 WP-CLI,但我无法下载必要的文件(includes/functions.php)。

这是我正在使用的命令:

bash bin/install-wp-tests.sh wordpress_test root '' localhost latest
Run Code Online (Sandbox Code Playgroud)

这是输出:

+ install_wp
+ '[' -d /tmp/wordpress/ ']'
+ return
+ install_test_suite
++ uname -s
+ [[ Linux == \D\a\r\w\i\n ]]
+ local ioption=-i
+ '[' '!' -d /tmp/wordpress-tests-lib ']'
+ cd /tmp/wordpress-tests-lib
+ '[' '!' -f wp-tests-config.php ']'
+ download https://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php /tmp/wordpress-tests-lib/wp-tests-config.php
++ which curl
+ '[' /opt/lampp/bin/curl ']'
+ curl -s https://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php
+ sed -i 's:dirname( __FILE__ ) . '\''/src/'\'':'\''/tmp/wordpress/'\'':' /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed …
Run Code Online (Sandbox Code Playgroud)

wordpress proxy plugins phpunit wp-cli

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

标签 统计

jestjs ×1

phpunit ×1

plugins ×1

proxy ×1

vue-router ×1

vue.js ×1

wordpress ×1

wp-cli ×1