如何确保Babel正在转译我的Jasmin spec文件?

时间:2018-10-23 05:35:01

标签: javascript jasmine babel

我在babel-jasmine集成下阅读了this section,所以我将jasmine.json文件更改为:

{
    "spec_dir": "spec",
    "spec_files": [
        "../src/**/*[sS]pec.js"
    ],
    "helpers": [
        "../node_modules/@babel/register/lib/node.js"
    ],
    "stopSpecOnExpectationFailure": false,
    "random": true
}

这是我唯一的测试文件:

describe("A suite", () => {
    it("contains spec with an expectation", () => {
        expect(true).toBe(true);
    });
});

.bebelrc

{
    "presets": [
        [
            "@babel/preset-react", {

            },
            "@babel/preset-env"
        ],
        [
            "@babel/preset-env",
            {
                "targets": {
                    "ie": 7,
                    "edge": "17",
                    "firefox": "60",
                    "chrome": "10",
                    "safari": "11.1",
                    "esmodules": false
                },
                "useBuiltIns": "usage"
            }
        ]
    ]
}

package.json

"devDependencies": {
    "@babel/cli": "^7.1.2",
    "@babel/core": "^7.1.2",
    "@babel/preset-env": "^7.1.0",
    "@babel/preset-react": "^7.0.0",
    "@babel/register": "^7.0.0",
    "babel-loader": "^8.0.4",
    "clean-webpack-plugin": "^0.1.19",
    "cross-env": "^5.2.0",
    "css-loader": "^1.0.0",
    "cssnano": "^4.1.4",
    "file-loader": "^2.0.0",
    "git-revision-webpack-plugin": "^3.0.3",
    "html-webpack-plugin": "^3.2.0",
    "jasmine": "^3.2.0",
    "less": "^3.8.1",
    "mini-css-extract-plugin": "^0.4.3",
    "optimize-css-assets-webpack-plugin": "^5.0.1",
    "postcss-safe-parser": "^4.0.1",
    "speed-measure-webpack-plugin": "^1.2.3",
    "style-loader": "^0.22.1",
    "url-loader": "^1.1.1",
    "webpack": "^4.20.2",
    "webpack-bundle-analyzer": "^2.13.1",
    "webpack-cli": "^3.1.2",
    "webpack-jarvis": "^0.3.2",
    "webpack-serve": "^2.0.2"
},
"dependencies": {
    "@babel/polyfill": "^7.0.0",
    "react": "^16.5.2",
    "react-dom": "^16.5.2"
}

我的节点版本:v10.9.0(测试可能会在较低的npm版本下运行一天)

当前,我的测试通过了。但是他们甚至在我使用通天塔来转送它们之前就已经过去了。

我有2个问题:

  1. 我如何知道babel正在向哪个版本的ES传输测试文件?
  2. 我可以在测试中使用哪种语法/功能来确保babel确实在做某事?

0 个答案:

没有答案