tomwayson / esri-rollup-example

Example application using Rollup to bundle local ES2015 modules that use CDN hosted modules from the ArcGIS API for JavaScript
http://tomwayson.github.io/esri-rollup-example/
23 stars 4 forks source link

add tests #16

Closed tomwayson closed 6 years ago

tomwayson commented 8 years ago

Unit tests are going to be tricky w/ out an intermediary build step that generates unbundled ES5 AMD modules.

Should be relatively straight forward to add an e2e test for side panel title and collapse using the Intern.

tomwayson commented 8 years ago

I tried getting Ava to require babel-core and transpile the source before running unit tests, but you have to configure it to use different presets than "es2015-rollup", which is what is specified in .babelrc and needed by Rollup. However, I could not get that to work with the following package.json config:

  "ava": {
    "require": [
      "babel-register"
    ],
    "babel": {
      "babelrc": false,
      "presets": [
        "es2015"
      ]
    }
  },
  "babel": {
    "presets": [
      "es2015"
    ]
  }

I get this error:

c:\code\git\esri-rollup-example\src\app\utils.js:5
import capitalize from '../../node_modules/lodash-es/capitalize';
^^^^^^

SyntaxError: Unexpected token import

Which implies to me that the es2015 preset is not getting applied to utils.js. Furthermore, I can tell that it's using the preset in .babelrc, b/c if I change that preset to just "es2015", I am able to get past that error and I get a new one from the lodash capitalize module:

c:\code\git\esri-rollup-example\node_modules\lodash-es\capitalize.js:1
(function (exports, require, module, __filename, __dirname) { import toString from './toString';
                                                              ^^^^^^

SyntaxError: Unexpected token import

That implies to me that the utils.jst file was transpiled, but the lodash capitalize.js file was not transpiled, or not correctly.

tomwayson commented 6 years ago

Closing this as I'm deprecating this repo in favor of using esri-loader.