2

I have an existing project written ecmascript5. The project has no tests and I would like to add. I used jasmine & mocha lightly (not lately...) and now I read about AVA (es6 out of the box)+Sinon and I really like it and I would like to try it.

There are several things I have problem figuring out (perhaps not possible) and I'll appreciate your insights.

I have a file 1.js and I would like to create tests for it at 1.test.js How can I import\use objects\methods from there? I need to refactor the file to export es6 modules or there is an alternative solution? Furthermore, what happens if this file depends on jquery for example?

As I see it now, I need to convert my project to a full es6 project with babel+bundler(webpack) and then I'm good to go.

Another idea, is there a way for Ava to load a page, which loads all the scripts using script tags and thus everything will be available?

Do you have other suggestions?

Any help would be appreciated.

Sindre Sorhus
  • 62,972
  • 39
  • 168
  • 232
Gal Ziv
  • 6,890
  • 10
  • 32
  • 43
  • I upvoted this to help get it out of the hole. I'm not sure why it got downvoted, seems to me a fair and honest question. – John Lockwood Oct 09 '16 at 23:57

1 Answers1

1

I ended up using es6 style. I exported assests from es5 files.

Gal Ziv
  • 6,890
  • 10
  • 32
  • 43
  • 1
    Cool. Thanks for posting the answer. The question wasn't the one I was looking for, but I was glad to find it anyway. – John Lockwood Oct 09 '16 at 23:58
  • manually. I migrated prototypes to class... you have es5 to es6 converters but I preffer doing this transformation manually. – Gal Ziv Dec 19 '16 at 17:01