Skip to content

compilers deprecation no mocha e babel #11

@guilhermelucasfreitas

Description

@guilhermelucasfreitas

eu mudei
--compilers js:babel-core/register
para

`--require babel-core/register`

como estava escrito na documentação do mocha https://github.com/mochajs/mocha/wiki/compilers-deprecation

Pois bem, eu alterei e surgiu o seguinte erro:

```

C:\Users\Ranulfo\Desktop\noderest>npm run test-integration

> noderest@1.0.0 test-integration C:\Users\Ranulfo\Desktop\noderest
> mocha --opts test/integration/mocha.opts test/integration/*.js

C:\Users\Ranulfo\Desktop\noderest\test\integration\helpers.js:1
(function (exports, require, module, __filename, __dirname) { import supertest f
rom 'supertest';
                                                              ^^^^^^

SyntaxError: Unexpected token import
Para mais detalhes do código:

mocha.opts que esta localizado em - test/integration/mocha.opts

--require test/integration/helpers.js
--reporter spec
--require babel-core/register
--slow 5000

package.json

{
"name": "noderest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "babel-node ./index.js",
"test": "echo "Error: no test specified" && exit 1",
"test-integration": "mocha --opts test/integration/mocha.opts test/integration/*.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-node6": "^11.0.0",
"babel-preset-stage-2": "^6.24.1",
"babel-register": "^6.26.0",
"chai": "^4.1.2",
"mocha": "^5.2.0",
"supertest": "^3.1.0"
},
"dependencies": {
"express": "^4.16.3",
"sequelize": "^4.37.10",
"sqlite3": "^4.0.0"
}
}


.babelrc

    {
      "presets": ["env"]
    }


helpers.js (test/integration/helpers.js)

import supertest from 'supertest';
import chai from 'chai';
import app from '../../app';

global.app = app;
global.request = supertest(app);
global.expect = chai.expect;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions