开玩笑/伪造者-意外令牌

时间:2019-03-18 23:20:55

标签: jestjs babel puppeteer babel-jest

当我尝试运行测试时,我不断收到The file’s entries are lines beginning with any of the forms specified by the variable ‘diary-date-forms’, which by default uses the forms of ‘diary-american-date-forms’: MONTH/DAY MONTH/DAY/YEAR MONTHNAME DAY MONTHNAME DAY, YEAR DAYNAME 错误。我已经研究了多个github问题,并且普遍共识是在使用v7时将unexpected token ';'更改为.babelrc

但是,我仍然不断收到此错误。

请清楚一点,这些测试在更改目录结构之前一直有效。

先前的结构为-

babel.config.js

当前修订的目录结构

root/test/test.spec.js

通过npx运行测试-root/test/e2e/tests/users/add.spec.js

package.json

npx jest --forceExit "test/e2e/tests/*"

babel.config.js

"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"
    }
  },

test.spec.js

module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        targets: {
          node: 'current'
        },
      },
      'jest'
    ]
  ],
  env: {
    test: {
      plugins: ['@babel/plugin-transform-modules-commonjs']
    }
  }
}

1 个答案:

答案 0 :(得分:3)

该行是无效的JavaScript。

一个const declaration requires a value

将该行更改为此:

let browser;

...错误应该消失了。