2

Is it possible at all? When I try to import Intern like this in my tests:

import * as registerSuite from 'intern!object'

and then I run webpack to transpile my *.ts tests, I get the following error:

TS2307: Cannot find module 'intern!object'.

Should I add some typings? I'm new to TypeScript, and webpack, and Intern — cannot understand what I'm missing.

Anatoly U
  • 258
  • 1
  • 11

2 Answers2

1

Yes you need to add a reference to intern typings in include section of your tsconfig.json, as described in this tutorial.

But this will only get you past the compilation step. At runtime, you need a loader that understands module references like intern!object and handles them exactly in the way intern is expecting them to work.

I don't know if any such loader or plugin exists for webpack, I can only find one issue about it in the intern repo, and it does not seem to have any resolution.

In general, Intern 3 relies on dojo loader which is bundled with intern. People who try to use other loaders are on their own, and no common solution has emerged.

For intern 4 (which is a major update and not released yet), there is a plan to 'remove loader dependency from Intern', but I don't know if something specific will be done (or even needs to be done) for supporting webpack.

artem
  • 46,476
  • 8
  • 74
  • 78
1

Actually, this is possible, as Dylan Schiemann said — the CEO at SitePen, the company that made Intern (if I'm not mistaken): https://www.sitepen.com/blog/2015/03/24/testing-typescript-with-intern/#comment-3280004472

The proof of this concept is the Dojo 2 project, which is also made by SitePen: https://github.com/dojo/widget-core/ It is authored in TypeScript, and uses webpack and Intern for testing.

But unfortunately there's no documentation tutorial on how to do this yet.

Dylan also said, in the next version of Intern (v4) the internal Intern's loader will be removed, and thus, this problem will go away, but Intern 4 is currently in pre-beta state yet, though relatively stable.

Anatoly U
  • 258
  • 1
  • 11