theintern / intern

A next-generation code testing stack for JavaScript.
https://theintern.io/
Other
4.36k stars 309 forks source link

Add a `globals` option to configure automatically installed globals #1139

Open jason0x43 opened 4 years ago

jason0x43 commented 4 years ago

Allow test interfaces and assertions to be added to the global namespace, making testing writing simpler.

By default, the only thing added to the global space should be the existing intern object.

A globals config option should allow the user to specify one of the built-in interfaces and/or one of the built-in assertion modules to be added to the global namespace.

{
  "globals": {
    "interface": "bdd",
    "assertions": "expect"
  }
}

To support typing, .d.ts files should be added to a globals directory in the intern package that declare these globals. A tsconfig could then include relevant ones:

{
  "files": [
    "node_modules/intern/globals/bdd.d.ts"
  ]
}
jason0x43 commented 4 years ago

Let's see how well the simplified imports (#1120) work before adding globals.