很抱歉我的英语水平不好.我try 为vuejs编写e2e测试.我用 cypress 来做这个.但有一个问题.此问题是网页包错误.导入thirdy包后发生错误.
我的 cypress 测试:
import { faker } from '@faker-js/faker';
const username = faker.internet.userName();
const password = faker.internet.password();
it('form elements should be correct', () => {
cy.get(userLoginElement.username).type(username).should('have.value', username);
cy.get(userLoginElement.password).type(password).should('have.value', password);
cy.get(userLoginElement.loginButton).should('exist');
});
我的 cypress .json文件:
{
"pluginsFile": "tests/e2e/plugins/index.js",
"baseUrl": "http://127.0.0.1:8080"
}
我的cypress插件文件
module.exports = (on, config) => {
return Object.assign({}, config, {
fixturesFolder: 'tests/e2e/fixtures',
integrationFolder: 'tests/e2e/specs',
screenshotsFolder: 'tests/e2e/screenshots',
videosFolder: 'tests/e2e/videos',
supportFile: 'tests/e2e/support/index.js'
})
}
我的软件包版本:
"faker": "^6.6.6",
"@vue/cli-plugin-e2e-cypress": "~5.0.0",
"@vue/cli-plugin-unit-jest": "~5.0.0",
"cypress": "^8.3.0",
运行vue-cli-service test:e2e后抛出以下错误
Error: Webpack Compilation Error
./node_modules/@faker-js/faker/dist/esm/chunk-4J2PVEV7.mjs 1:1430
Module parse failed: Unexpected token (1:1430)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
可能是版本导致了错误?