我是Lightning Web Component(LWC)单元测试的初学者。我在使用lwc-jest Node.js依赖测试我的LWC组件时遇到了问题。我在sourceApiVersion配置方面遇到了一些困难。当我运行测试时,测试显示
PS C:\Users\rdesai\Documents\GitHub\nimbusdevv> npm run test:unit
> nimbusdevv@1.0.0 test:unit C:\Users\rdesai\Documents\GitHub\nimbusdevv
> lwc-jest
error Invalid sourceApiVersion found in sfdx-project.json. Expected 47.0, found 45.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nimbusdevv@1.0.0 test:unit: `lwc-jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nimbusdevv@1.0.0 test:unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\rdesai\AppData\Roaming\npm-cache\_logs\2019-11-21T19_21_35_974Z-debug.log但是,当我使用sfdx plugins --core检查我的salesforcedx的当前状态时,它显示API版本为47。
PS C:\Users\rdesai\Documents\GitHub\nimbusdevv> sfdx plugins --core
@oclif/plugin-commands 1.2.3 (core)
@oclif/plugin-help 2.2.1 (core)
@oclif/plugin-not-found 1.2.3 (core)
@oclif/plugin-plugins 1.7.8 (core)
@oclif/plugin-update 1.3.9 (core)
@oclif/plugin-warn-if-update-available 1.7.0 (core)
@oclif/plugin-which 1.0.3 (core)
@salesforce/sfdx-trust 3.0.5 (core)
analytics 1.2.1 (core)
generator 1.1.1 (core)
salesforcedx 47.6.2 (core)
├─ salesforcedx-templates 47.6.2 (core)
└─ salesforce-alm 47.9.0 (core)
sfdx-cli 7.33.2 (core)希望有人能帮我弄清楚我哪里错了。
发布于 2020-11-13 20:49:11
检查位于项目根目录中的sfdx-project.json文件,并在文件中将API版本从45.0更改为47.0。
https://stackoverflow.com/questions/58984040
复制相似问题