问题描述
import cv2
im = cv2.imread('lines.png',cv2.IMREAD_GRAYSCALE)
# Count objects - initially 2
nObjects = len(cv2.findContours(im,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)[0])
# Draw white line connecting white px 1 and white px 2
cv2.line(im,(w1x,w1y),(w2x,w2y),255,1)
# Count objects - still 2
nObjects = len(cv2.findContours(im,cv2.CHAIN_APPROX_SIMPLE)[0])
# Draw white line connecting white px 1 and white px 3
cv2.line(im,(w3x,w3y),1)
# Count objects - Now just 1
nObjects = len(cv2.findContours(im,cv2.CHAIN_APPROX_SIMPLE)[0])
由于某种原因,它收到如下错误:
import { ReactComponent as bestSeller } from "../../collection/images/icons/hello.svg";
我在 ● Test suite Failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse,e.g. it's not plain JavaScript.
By default,if Jest sees a Babel config,it will use that to transform your files,ignoring "node_modules".
Here's what you can do:
• If you are trying to use ECMAScript Modules,see https://jestjs.io/docs/en/ecmascript-modules for how to enable it.
• To have some of your "node_modules" files transformed,you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
C:\*********collections\images\icons\hello.svg:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path class="a" d="M1667.949,842.606,1657,853.559l.048,5,.049L1673,847.653Zm3.028,5.047-.478.478-3.028-3.028.478-.478Zm-9.521,9.52-3-.029-.029-3,8.033-8.033,1.01,1.01-7.741,7.74,1.009,7.741-7.74,1.009Z" transform="translate(-1656.996 -842.606)"/></svg>
^
SyntaxError: Unexpected token '<'
中的 Jest 配置如下所示:
package.json
使用“babel-jest”:“24.7.1” 和
"jest": {
"verbose": true,"snapshotSerializers": [
"enzyme-to-json/serializer"
],"setupFiles": [
"<rootDir>/src/setupTests.js"
]
},
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)