Has anyone written jasmine / jest tests using es2015 syntax? how much shimming / polyfill / gerrymandering does it require?
im failed to import functions correctly. I have one module: .... / utils / TweetUtils.js
'use strict'; export function getListOfTweetIds (tweets) { return Object.keys(tweets); };
and one test package:
.... / __ tests __ / TweetUtils-test.js
'use strict'; jest.dontMock('../TweetUtils'); import * as TweetUtils from '../TweetUtils'; describe('Tweet utilities module', () => { it('has access to the TweetUtils methods', () => { let testObj = {a:'a',b:'b',c:'c'};
If I crack the console output into a package with something like this: expect('').toBe(TweetUtils);
Jasmine reports this:
- Expected: '' toBe: { default: { getListOfTweetIds: Function }, getListOfTweetIds: Function }
So, it looks like the import statement is doing something, but is not explicitly importing my methods honestly. I get the same results when importing using a syntax with a named function: import {getListOfTweetIds} from '../TweetUtils'; But if I use the default syntax: import getListOfTweetIds from '../TweetUtils'; The second spec doesn't work - its no longer a typeof function , but a typeof object // => {default: Function}
I combed documents and open problems. There have been related problems for several months, but known problems do not seem to be correct. Ive tried to import my jest.dontMock instructions to avoid getting up, around: https://github.com/babel/babel-jest/issues/16 , but not cubes.
Everything works if I modify TweetUtils.js to use module.exports = function… and transfer it to the set using const myFunction = require('../TweetUtils') , but it doesn’t feel like I'm imposing the true magic of ES2015. Are all dealing with erratic workarounds now while the ecosystem is catching up with new syntax?