在具有 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) 我正在尝试在 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)