Я получаю ошибку unexpected token ';'
, когда пытаюсь запустить свои тесты. Я просмотрел несколько проблем с GitHub, и общее согласие заключается в том, чтобы изменить .babelrc
на babel.config.js
при использовании v7.
однако, я все еще получаю эту ошибку.
Просто чтобы прояснить, эти тесты работали, пока я не изменил свою структуру каталогов.
предыдущая структура была -
root/test/test.spec.js
текущая пересмотренная структура каталога
root/test/e2e/tests/users/add.spec.js
выполнение тестов через npx - npx jest --forceExit "test/e2e/tests/*"
package.json
"dependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.3.4",
"@babel/register": "^7.0.0",
"assert": "^1.4.1",
"babel-core": "^7.0.0-bridge.0",
"chai": "^4.2.0",
"jest-puppeteer": "^4.0.0",
"regenerator-runtime": "^0.13.1",
"screen-info": "^1.0.1",
"screenres": "^2.0.1"
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.2.0",
"@babel/preset-env": "^7.3.4",
"babel-jest": "^24.5.0",
"babel-preset-env": "^1.7.0",
"babel-preset-jest": "^24.3.0",
"babel-core": "7.0.0-bridge.0",
"jest": "^24.5.0",
"jest-cli": "^24.5.0",
"puppeteer": "^1.13.0"
},
"jest": {
"transformIgnorePatterns": [
"/node_modules/(?!@babel).+\\.js$"
],
"transform": {
"^.+\\.jsx?$": "babel-jest"
}
},
babel.config.js
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current'
},
},
'jest'
]
],
env: {
test: {
plugins: ['@babel/plugin-transform-modules-commonjs']
}
}
}
test.spec.js
import puppeteer from "puppeteer";
const chai = require('chai');
const assert = chai.assert; // Using Assert style
const expect = chai.expect; // Using Expect style
const should = chai.should(); // Using Should style
const CheckMethods = require('../../methods/common/checks');
const config = require('../../../../config/config');
let page;
const browser; //ERROR HERE AT ';'
describe('Super Suite', () => {
const checks = new CheckMethods();
beforeEach(async () => {
browser = await puppeteer.launch(config.puppeteer);
page = await browser.newPage();
await page.setViewport(config.browser);
await page.goto(`${config.ui_endpoint}/super/#login`, {
waitUntil: 'networkidle2'
})
});
it('should be able to create a client', async () => {
await page.waitForSelector('#app-root > div > .content > .login-form > .btn')
await page.click('#app-root > div > .content > .login-form > .btn')
await page.waitForSelector('div > .header > #navbarNav > .navbar-nav > .nav-link:nth-child(1)')
await page.click('div > .header > #navbarNav > .navbar-nav > .nav-link:nth-child(1)')
const searchSelector = 'input.form-control.form-control-sm'
await page.waitForSelector(searchSelector)
await page.type(searchSelector, 'supra')
await page.waitForSelector('.clients-table > tbody > tr > td');
let emptyTable = await checks.isTableEmpty('.clients-table > tbody > tr > td', page)
if (emptyTable) {
await page.waitForSelector('.clients-list > .col-sm-12 > .card > .card-header > .btn')
await page.click('.clients-list > .col-sm-12 > .card > .card-header > .btn')
await page.waitForSelector('.card:nth-child(1) > .card-body > .form-horizontal > .form-group:nth-child(1) > .col-10 > .form-control')
await page.click('.card:nth-child(1) > .card-body > .form-horizontal > .form-group:nth-child(1) > .col-10 > .form-control')
await page.type('.card:nth-child(1) > .card-body > .form-horizontal > .form-group:nth-child(1) > .col-10 > .form-control', 'supra')
await page.type('.card:nth-child(1) > .card-body > .form-horizontal > .form-group:nth-child(2) > .col-10 > .form-control', 'supra distribution')
await page.select('.card-body > .form-horizontal > .form-group > .col-10 > .ui-select', '3pl')
await page.select('.card-body > .form-horizontal > .form-group > .col-10 > .ui-select', 'distributor')
await page.type('.card-body > .form-horizontal > .form-group > .col-10 > .ui-select', 'distributor')
await page.type('.client-user-form > .card-body > .form-horizontal > .form-group:nth-child(1) > .col-10 > .form-control', 'james')
await page.type('.client-user-form > .card-body > .form-horizontal > .form-group:nth-child(2) > .col-10 > .form-control', 'james@pineapple.io')
await page.type('.client-user-form > .card-body > .form-horizontal > .form-group:nth-child(3) > .col-10 > .form-control', 'omnium123')
await page.waitForSelector('.card-deck > .card > .card-header > .buttons-container > .btn')
await page.click('.card-deck > .card > .card-header > .buttons-container > .btn')
await page.waitForSelector('div.card-header.section-menu.clearfix > span')
await page.waitForSelector('div > .header > #navbarNav > .navbar-nav > .nav-link:nth-child(1)')
await page.click('div > .header > #navbarNav > .navbar-nav > .nav-link:nth-child(1)')
await page.waitForSelector(searchSelector)
await page.type(searchSelector, 'supra')
await page.waitForSelector('.clients-table > tbody > tr > td');
emptyTable = await checks.isTableEmpty('.clients-table > tbody > tr > td', page)
await page.waitFor(2000)
assert.isFalse(emptyTable)
} else {
await page.waitFor(2000)
assert.isFalse(emptyTable);
}
}, 10000),
afterEach(async () => {
await browser.close();
});
})
```