How to write Jest transformIgnorePatterns

后端 未结 4 2113
独厮守ぢ
独厮守ぢ 2021-02-19 02:52

I have this excpetion

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 p         


        
4条回答
  •  长发绾君心
    2021-02-19 03:05

    Actually, it seems like typescript is not going well with JEST test cases, so what i feel like either JEST need to ignore those files or those packages need to be transpiled to js code which JEST can understand,

    you can try this

    "transformIgnorePatterns": [ "node_modules/(?!(@microsoft/sp-core-library))" ],
    

    and in tsconfig.json

    "allowJs": true,
    

    for more details please check this post

    https://github.com/SharePoint/sp-dev-docs/issues/2325#issuecomment-446416878

提交回复
热议问题