我有一个 vue.js 应用程序,我使用以下指令安装了 Jest:
https://vue-test-utils.vuejs.org/guides/testing-single-file-components-with-jest.html。
当我运行npm test 时,出现错误。
? Test suite failed to run
TypeError: Cannot set property '_eventListeners' of undefined
at Window.close (node_modules/jsdom/lib/jsdom/browser/Window.js:475:51)
Run Code Online (Sandbox Code Playgroud)
我已经完成了文档中的所有内容,关于该应用程序的所有其他内容都很好,除了测试。请问,我该如何解决这个问题?
这是我的 package.json 配置文件:
{
"name": "vendor",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"test": "jest"
},
"dependencies": {
"babel-polyfill": "^6.26.0",
"vue": "^2.5.22",
"vue-router": "^3.0.2",
"vuetify": "^1.3.0"
},
"devDependencies": {
"vue-server-renderer": "^2.6.6",
"babel-core": "^6.26.3",
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.3.1",
"@vue/cli-plugin-babel": "^3.4.0",
"@vue/cli-plugin-eslint": "^3.4.0",
"@vue/cli-service": "^3.4.0",
"@vue/server-test-utils": …Run Code Online (Sandbox Code Playgroud) 我想检查我的dummy.csv是否存在于我的本地系统中。如果存在,则将显示此检查欺诈状态,否则不会显示。我不想使用 JavaScript。如果有任何与 python jinja有关的解决方案,请帮助我。
还有一件事如何import os在 html 页面中使用 jinja?
我曾尝试过这个:
布局.html
{% if os.path.exists('./static/userdata/dummy.csv') %}
<a class="nav-item nav-link" href="{{ url_for('checkfraudstatus') }}">Check Fraud Status</a>
{% endif %}
Run Code Online (Sandbox Code Playgroud)
错误
jinja2.exceptions.UndefinedError: 'os' is undefined
Run Code Online (Sandbox Code Playgroud) 在我的项目中,我使用了 bootstrap v.5 卡。我想让图像成为一个完美的圆形,我使用了 bootstrap class="rounded-circle" 但输出图像的形状呈椭圆形。这是我的代码,
<img src={elonMusk} class="card-img-top rounded-circle" alt={elonMusk} />
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
html ×2
babel-jest ×1
bootstrap-5 ×1
css ×1
javascript ×1
jestjs ×1
jinja2 ×1
python ×1
python-3.x ×1
vue.js ×1