Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting wallaby and mocha testing working in an aurelia /typescript project #1

Open
pavsaund opened this issue Dec 4, 2019 · 1 comment
Labels
bug Something isn't working enhancement New feature or request

Comments

@pavsaund
Copy link

pavsaund commented Dec 4, 2019

I've been struggling to get typescript testing up and running in our aurelia project, and have hit several hurdles that could be made easier by the build / tooling pipeline. Some have been fixed locally, while others need changes to the underlying tools pipeline to make them work.

Wallaby

Based on a lot of ping-ponging: I got wallaby working based on what you see in this repository: https://github.com/pavsaund/wallaby-dolittle-aurelia-mixed-js-ts

wallaby.config.js with workarounds
const build = require('@dolittle/typescript.build');

module.exports = build.wallaby((wallaby, settings) => {
    settings.compilers = {
            '**/*.@(js|ts)': wallaby.compilers.typeScript({
            module: 'commonjs',
            downlevelIteration: true,
            allowJs: true,
            experimentalDecorators: true,
            esModuleInterop: true,
+           outDir: './any', // fix to make js files available for the typescript transpiler in wallaby
            target: 'es6'
        })
    }

+   // fix to transpile js files in wallaby
+   settings.preprocessors = {
+       '**/*.jsts': file => file.changeExt('js').content
+   }

+    // Fix to ignore a local custom folder
+    settings.files.push({ pattern: 'aurelia_project/**/*', ignore: true});


+}, (wallaby, setup) => {
+   // Fix to be able to test aurelia components using ex: decorators
+   require('aurelia-polyfills');
+});

These could be then made into three issues:

  • Add support / setting to allow mixed js/ts compilation in wallaby (since dolittle proxies are still js)
  • Add mechanism for wallaby setup to respect ignored files in ex: tsconfig
  • Add the aurelia-polyfills package automatically - since it's required for testing

Mocha

Hitting several similar issues with mocha-testing, but without a good long-term workaround. The biggest issue has been to be able to build the project, which failed due to a bugfix in typescript 3.7, which aurelia-vaildation needs to fix.

Local fix is to lock typescript dependency used by the build package like so:

package.json workaround
{
...
  "resolutions": {
    "@dolittle/typescript.build/typescript": "^3.6.4"
  },
...
}

It would be convenient if the used typescript was forced to 3.6.x by the TypeScript.Webpack.Aurelia-package, so that it can be fixed for all projects using this combination.

  • Mechanism for mocha setup to respect ignored/excluded files in ex: tsconfig - No workaround
  • Mechanism to support adding required test dependencies ex aurelia-polyfills - No workaround
  • Lock version of typescript to 3.6.X while aurelia-validation fixes their bugs (perhaps this is a project-specific fix?)
@pavsaund
Copy link
Author

pavsaund commented Dec 4, 2019

The most pressing issues are the two for the mocha setup (ignored files and including dependencies), since these don't have any local workarounds

@pavsaund pavsaund added bug Something isn't working enhancement New feature or request labels Dec 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant