Wallaby on CLI generated project

I am trying to setup a new, clean install to start building out a V2 app project and actually trying to do a TDD type coding process.

I am using WallabyJS to get that immediate feedback when things are good, or bad so am working to get that setup and error free with a fresh install. I have the project setup as a Karma/Jasmine project and have successfully ran all the project default tests just fine.

However I am getting an error in the Wallaby console as noted below. I think I can probably ignore that, but was wondering if there is a way to tell it to ignore the Aurelia files in this case as they are not part of the desired source testing. I’d like to clean up any possible distractions before I start.

Anyway to do that, that someone has already figured out?
I have also included my wallaby.js file below as well.

Wallaby console error

[Info]  Started Wallaby.js Core v1.0.702
[Info]  Wallaby App (realtime reports) is available at: http://localhost:51245
[Error] Runtime error: TypeError: Reflect.getOwnMetadata is not a function 
[Error]     at Object.getOwn (G:\2019\Aurelia-TS-Wallaby\xcell-client-v2\node_modules\aurelia-metadata\dist\commonjs\aurelia-metadata.js:41:20) 
[Error]     at deco (G:\2019\Aurelia-TS-Wallaby\xcell-client-v2\node_modules\aurelia-dependency-injection\dist\commonjs\aurelia-dependency-injection.js:724:50) 
[Error]     at autoinject (G:\2019\Aurelia-TS-Wallaby\xcell-client-v2\node_modules\aurelia-dependency-injection\dist\commonjs\aurelia-dependency-injection.js:732:28) 
[Error]     at __decorate (.\src\users.js:11:73) 
[Error]     at .\src\users.js:250:28 
[Error]     at Object.<anonymous> (.\src\users.js:255:2) 
[Error]     at Module._compile (internal/modules/cjs/loader.js:701:30) 
[Error]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10) 
[Error]     at Module.load (internal/modules/cjs/loader.js:600:32) 
[Error]     at tryModuleLoad (internal/modules/cjs/loader.js:539:12) 
[Error]     at Function.Module._load (internal/modules/cjs/loader.js:531:3) 
[Error]     at Module.require (internal/modules/cjs/loader.js:637:17) 
[Error]     at require (internal/modules/cjs/helpers.js:22:18) 
[Error]     at Object.<anonymous> (.\test\unit\users.spec.js:4:29) 
[Error]     at Module._compile (internal/modules/cjs/loader.js:701:30) 
[Error]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10) 
[Error]     at Module.load (internal/modules/cjs/loader.js:600:32) 
[Error]     at tryModuleLoad (internal/modules/cjs/loader.js:539:12) 
[Error]     at Function.Module._load (internal/modules/cjs/loader.js:531:3) 
[Error]     at Module.require (internal/modules/cjs/loader.js:637:17) 
[Error]     at require (internal/modules/cjs/helpers.js:22:18) 
[Error]     at G:\2019\Aurelia-TS-Wallaby\xcell-client-v2\node_modules\jasmine\lib\jasmine.js:89:5 
[Error]     at Array.forEach (<anonymous>) 
[Error]     at Jasmine.loadSpecs (G:\2019\Aurelia-TS-Wallaby\xcell-client-v2\node_modules\jasmine\lib\jasmine.js:88:18) 
[Error]     at Jasmine.execute (G:\2019\Aurelia-TS-Wallaby\xcell-client-v2\node_modules\jasmine\lib\jasmine.js:259:8) 
[Error]     at WebSocket.emit (events.js:189:13) 
[Error]     at afterWrite (_stream_writable.js:480:3) 
[Error]     at onwrite (_stream_writable.js:471:7) 
[Error]     at InflateRaw.afterTransform (_stream_transform.js:94:3) 
[Error]     at Zlib.processCallback (zlib.js:626:8) 
[Info]  Finished executing 10 affected test(s)

wallaby.js

module.exports = function (wallaby)
{
    var path = require('path');

    process.env.NODE_PATH += path.delimiter + wallaby.projectCacheDir + path.delimiter + 'src';

    return {

        debug: false,

        files: [
            //{ pattern: 'node_modules/chai/chai.js', instrument: false, load: true },
            { pattern: 'tsconfig.json' },
            { pattern: 'src/**/*.ts' },
            { pattern: 'src/**/*.html' },
            { pattern: 'test/**/*.ts' },
            { pattern: '!test/unit/**/*.spec.ts' }
        ],

        tests: ['test/unit/**/*.spec.ts'],

        env: {
            type: 'node',
            runner: 'node'
        },

        testFramework: 'jasmine',

        compilers: {
            '**/*.ts': wallaby.compilers.typeScript({
                module: 'commonjs',
                baseUrl: './src'
            })
        },

        // //executed in test framework context
        // setup: function (wallaby) 
        // {
        //     sinon-chai.use(require('chai-datetime'));
        // }
    };
};
1 Like

Just a quick observation…
I created another fresh project install and this time used Jest.
No errors, and all tests run clean.

2 Likes

That’s a missing api needs polyfill.
test/jest-pretest.js has import 'aurelia-polyfills'; to cover those polyfill.

If you use karma+jasmine, the test/unit/setup.js should have aurelia-polyfills too. Import it if it’s not there.

2 Likes

Or use the commented out setup function from the wallabyjs file to perform the import.

1 Like

I managed to get it working with Karma/Jasmine with au-cli v 1.0.2

The wallaby.config.js file was essentially copied from this repo

2 Likes

So it appears to be loading the standard provided setup.ts that has that import.
I enabled debug and here is the wallaby output, that shows it loading the files, and running 10 of the tests successfully. Then failing on the noted error…

[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:project Wallaby Node version: v10.15.3
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:project Wallaby config: G:\2019\Aurelia-TS-Wallaby\xcell-client-v2-jasmine\wallaby.js
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: tsconfig.json
[Info]  Started Wallaby.js Core v1.0.703
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: src/app.html
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: src/app.ts
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: src/blur-image.ts
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: src/child-router.ts
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: src/child-router.html
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: src/environment.ts
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: src/main.ts
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: src/nav-bar.html
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: src/users.html
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: src/users.ts
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: src/welcome.html
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: src/welcome.ts
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: src/resources/index.ts
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: test/unit/app.spec.ts
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: test/unit/child-router.spec.ts
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: test/unit/setup.ts
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: test/unit/users.spec.ts
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:fs File added: test/e2e/integration/app.e2e.ts
[Info]  Sun, 07 Jul 2019 01:30:15 GMT wallaby:project File cache: 
.
. snipped because of length
.
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:processor No compilers found for tsconfig.json
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:processor No compilers found for src/main.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File tsconfig.json is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project No preprocessors configured for tsconfig.json
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project Writing to disk and caching processed file tsconfig.json
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:processor No compilers found for src/nav-bar.html
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File src/main.ts is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project No preprocessors configured for src/main.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project Writing to disk and caching processed file src/main.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:processor No compilers found for src/users.html
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File src/nav-bar.html is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project No preprocessors configured for src/nav-bar.html
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project Writing to disk and caching processed file src/nav-bar.html
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File src/users.html is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project No preprocessors configured for src/users.html
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:processor No compilers found for src/users.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project Writing to disk and caching processed file src/users.html
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:processor No compilers found for src/app.html
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:processor No compilers found for src/welcome.html
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File src/users.ts is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project No preprocessors configured for src/users.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project Writing to disk and caching processed file src/users.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File tsconfig.json changes saved, store ts: 1562168034640, change ts: 1562463016242
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File src/app.html is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:processor No compilers found for src/welcome.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project No preprocessors configured for src/app.html
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project Writing to disk and caching processed file src/app.html
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File src/welcome.html is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:processor No compilers found for src/resources/index.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project No preprocessors configured for src/welcome.html
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project Writing to disk and caching processed file src/welcome.html
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File src/main.ts changes saved, store ts: 1562162753864, change ts: 1562463016244
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:processor No compilers found for test/unit/app.spec.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File src/welcome.ts is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project No preprocessors configured for src/welcome.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project Writing to disk and caching processed file src/welcome.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File src/resources/index.ts is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:processor No compilers found for test/unit/child-router.spec.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project No preprocessors configured for src/resources/index.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project Writing to disk and caching processed file src/resources/index.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File src/nav-bar.html changes saved, store ts: 1562162753866, change ts: 1562463016244
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File test/unit/app.spec.ts is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project No preprocessors configured for test/unit/app.spec.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project Writing to disk and caching processed file test/unit/app.spec.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File test/unit/child-router.spec.ts is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project No preprocessors configured for test/unit/child-router.spec.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project Writing to disk and caching processed file test/unit/child-router.spec.ts
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File src/users.html changes saved, store ts: 1562162753869, change ts: 1562463016245
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File src/users.ts changes saved, store ts: 1562162753872, change ts: 1562463016245
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File src/app.html changes saved, store ts: 1562162753857, change ts: 1562463016242
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File src/resources/index.ts changes saved, store ts: 1562162753874, change ts: 1562463016246
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File src/welcome.ts changes saved, store ts: 1562162753873, change ts: 1562463016246
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File test/unit/app.spec.ts changes saved, store ts: 1562168923574, change ts: 1562463016246
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File src/welcome.html changes saved, store ts: 1562162753869, change ts: 1562463016245
[Info]  Sun, 07 Jul 2019 01:30:17 GMT wallaby:project File test/unit/child-router.spec.ts changes saved, store ts: 1562162753877, change ts: 1562463016247
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:processor No compilers found for src/app.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File src/app.ts is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project No preprocessors configured for src/app.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Writing to disk and caching processed file src/app.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File src/app.ts changes saved, store ts: 1562162753854, change ts: 1562463016243
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:processor No compilers found for src/child-router.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File src/child-router.ts is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project No preprocessors configured for src/child-router.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Writing to disk and caching processed file src/child-router.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:processor No compilers found for src/environment.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File src/environment.ts is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project No preprocessors configured for src/environment.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Writing to disk and caching processed file src/environment.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File src/environment.ts changes saved, store ts: 1562164539505, change ts: 1562463016244
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File src/child-router.ts changes saved, store ts: 1562162753860, change ts: 1562463016243
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:processor No compilers found for src/child-router.html
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File src/child-router.html is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project No preprocessors configured for src/child-router.html
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Writing to disk and caching processed file src/child-router.html
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File src/child-router.html changes saved, store ts: 1562162753862, change ts: 1562463016243
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File src/blur-image.ts changes are patches only: false
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File test/unit/setup.ts changes are patches only: false
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File test/unit/users.spec.ts changes are patches only: false
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File test/e2e/integration/app.e2e.ts changes are patches only: false
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Preparing to process src/blur-image.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Starting processor pool (if not yet started)
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Preparing to process test/unit/setup.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Starting processor pool (if not yet started)
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:processor No compilers found for src/blur-image.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Preparing to process test/unit/users.spec.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Starting processor pool (if not yet started)
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:processor No compilers found for test/unit/setup.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File src/blur-image.ts is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project No preprocessors configured for src/blur-image.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:processor No compilers found for test/unit/users.spec.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Writing to disk and caching processed file src/blur-image.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File test/unit/setup.ts is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project No preprocessors configured for test/unit/setup.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Writing to disk and caching processed file test/unit/setup.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Preparing to process test/e2e/integration/app.e2e.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Starting processor pool (if not yet started)
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:processor No compilers found for test/e2e/integration/app.e2e.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File test/unit/users.spec.ts is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project No preprocessors configured for test/unit/users.spec.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Writing to disk and caching processed file test/unit/users.spec.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File test/e2e/integration/app.e2e.ts is not instrumented by core
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project No preprocessors configured for test/e2e/integration/app.e2e.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Writing to disk and caching processed file test/e2e/integration/app.e2e.ts
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File test/unit/setup.ts changes saved, store ts: 1562162753822, change ts: 1562463018090
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File test/unit/users.spec.ts changes saved, store ts: 1562162753881, change ts: 1562463018090
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File src/blur-image.ts changes saved, store ts: 1562162753859, change ts: 1562463018090
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project File test/e2e/integration/app.e2e.ts changes saved, store ts: 1562162753854, change ts: 1562463018091
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Stopping process pool
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Running postprocessor
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:postprocessor New TypeScript language service is required
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:postprocessor TypeScript compiler options module (before tsconfig.json): 1
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:postprocessor TypeScript compiler options module (after tsconfig.json): 1
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Preparing to process src/app.js
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Preparing to process src/blur-image.js
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Preparing to process src/child-router.js
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Preparing to process src/environment.js
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Preparing to process src/main.js
[Info]  Sun, 07 Jul 2019 01:30:18 GMT wallaby:project Preparing to process src/resources/index.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Preparing to process src/users.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Preparing to process src/welcome.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Preparing to process test/e2e/integration/app.e2e.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Preparing to process test/unit/setup.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Preparing to process test/unit/app.spec.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Preparing to process test/unit/child-router.spec.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Preparing to process test/unit/users.spec.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Processing compiled src/app.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Instrumenting src/app.js, via process pool: false
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Processing compiled src/blur-image.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Instrumenting src/blur-image.js, via process pool: false
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Processing compiled src/child-router.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Instrumenting src/child-router.js, via process pool: false
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Processing compiled src/environment.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Instrumenting src/environment.js, via process pool: false
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Processing compiled src/main.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Instrumenting src/main.js, via process pool: false
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Processing compiled src/resources/index.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Instrumenting src/resources/index.js, via process pool: false
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Processing compiled src/users.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Instrumenting src/users.js, via process pool: false
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Processing compiled src/welcome.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Instrumenting src/welcome.js, via process pool: false
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Processing compiled test/e2e/integration/app.e2e.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Instrumenting test/e2e/integration/app.e2e.js, via process pool: false
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Processing compiled test/unit/setup.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Instrumenting test/unit/setup.js, via process pool: false
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Processing compiled test/unit/app.spec.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Instrumenting test/unit/app.spec.js, via process pool: false
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Processing compiled test/unit/child-router.spec.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Instrumenting test/unit/child-router.spec.js, via process pool: false
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Processing compiled test/unit/users.spec.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Instrumenting test/unit/users.spec.js, via process pool: false
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project No preprocessors configured for src/app.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project No preprocessors configured for src/blur-image.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project No preprocessors configured for src/child-router.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project No preprocessors configured for src/environment.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project No preprocessors configured for src/main.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project No preprocessors configured for src/resources/index.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project No preprocessors configured for src/users.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project No preprocessors configured for src/welcome.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project No preprocessors configured for test/e2e/integration/app.e2e.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project No preprocessors configured for test/unit/setup.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project No preprocessors configured for test/unit/app.spec.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project No preprocessors configured for test/unit/child-router.spec.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project No preprocessors configured for test/unit/users.spec.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Writing to disk and caching processed file src/app.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Writing to disk and caching processed file src/blur-image.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Writing to disk and caching processed file src/child-router.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Writing to disk and caching processed file src/environment.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Writing to disk and caching processed file src/main.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Writing to disk and caching processed file src/resources/index.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Writing to disk and caching processed file src/users.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Writing to disk and caching processed file src/welcome.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Writing to disk and caching processed file test/e2e/integration/app.e2e.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Writing to disk and caching processed file test/unit/setup.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Writing to disk and caching processed file test/unit/app.spec.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Writing to disk and caching processed file test/unit/child-router.spec.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Writing to disk and caching processed file test/unit/users.spec.js
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Postprocessor execution finished
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Test run started; run priority: 3
[Info]  Sun, 07 Jul 2019 01:30:19 GMT wallaby:project Running all tests
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers Starting test run, priority: 3
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers Distributing tests between 4 workers
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers Running tests in parallel
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:nodeRunner Starting sandbox [worker #0, session #eujjk]
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:nodeRunner Starting sandbox [worker #1, session #72d6v]
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:nodeRunner Starting sandbox [worker #2, session #yqvg9]
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:nodeRunner Starting sandbox [worker #3, session #l8gj1]
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:nodeRunner Preparing sandbox [worker #0, session #eujjk]
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:nodeRunner Preparing sandbox [worker #1, session #72d6v]
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:nodeRunner Preparing sandbox [worker #2, session #yqvg9]
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:nodeRunner Preparing sandbox [worker #3, session #l8gj1]
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:nodeRunner Prepared sandbox [worker #0, session #eujjk]
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:nodeRunner Prepared sandbox [worker #1, session #72d6v]
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:nodeRunner Prepared sandbox [worker #2, session #yqvg9]
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:nodeRunner Prepared sandbox [worker #3, session #l8gj1]
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [worker #0, session #eujjk] Running tests in sandbox
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [worker #1, session #72d6v] Running tests in sandbox
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [worker #2, session #yqvg9] Running tests in sandbox
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [worker #3, session #l8gj1] Running tests in sandbox
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [l8gj1] Loaded 0 test(s)
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [l8gj1] Run 0 test(s), skipped 0 test(s)
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [eujjk] Loaded 5 test(s)
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [l8gj1] Sandbox is responsive, closing it
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [eujjk] Test executed: contains a router property
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [eujjk] Test executed: should have a welcome route
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [eujjk] Test executed: should have a child router route
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [72d6v] Loaded 5 test(s)
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [eujjk] Test executed: configures the router title
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [eujjk] Test executed: should have a users route
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [72d6v] Test executed: should have a users route
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [72d6v] Test executed: should have a welcome route
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [72d6v] Test executed: configures the heading
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [72d6v] Test executed: should have a child router route
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [72d6v] Test executed: contains a router property
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [eujjk] Run 5 test(s), skipped 0 test(s)
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [eujjk] Sandbox is responsive, closing it
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [72d6v] Run 5 test(s), skipped 0 test(s)
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [72d6v] Sandbox is responsive, closing it
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers Sandbox (active) [yqvg9] error: Reflect.getOwnMetadata is not a function
[Error] Runtime error: TypeError: Reflect.getOwnMetadata is not a function 
[Error]     at Object.getOwn (G:\2019\Aurelia-TS-Wallaby\xcell-client-v2-jasmine\node_modules\aurelia-metadata\dist\commonjs\aurelia-metadata.js:41:20) 
[Error]     at deco (G:\2019\Aurelia-TS-Wallaby\xcell-client-v2-jasmine\node_modules\aurelia-dependency-injection\dist\commonjs\aurelia-dependency-injection.js:724:50) 
[Error]     at autoinject (G:\2019\Aurelia-TS-Wallaby\xcell-client-v2-jasmine\node_modules\aurelia-dependency-injection\dist\commonjs\aurelia-dependency-injection.js:732:28) 
[Error]     at __decorate (.\src\users.js:11:73) 
[Error]     at .\src\users.js:250:28 
[Error]     at Object.<anonymous> (.\src\users.js:255:2) 
[Error]     at Module._compile (internal/modules/cjs/loader.js:701:30) 
[Error]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10) 
[Error]     at Module.load (internal/modules/cjs/loader.js:600:32) 
[Error]     at tryModuleLoad (internal/modules/cjs/loader.js:539:12) 
[Error]     at Function.Module._load (internal/modules/cjs/loader.js:531:3) 
[Error]     at Module.require (internal/modules/cjs/loader.js:637:17) 
[Error]     at require (internal/modules/cjs/helpers.js:22:18) 
[Error]     at Object.<anonymous> (.\test\unit\users.spec.js:4:29) 
[Error]     at Module._compile (internal/modules/cjs/loader.js:701:30) 
[Error]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10) 
[Error]     at Module.load (internal/modules/cjs/loader.js:600:32) 
[Error]     at tryModuleLoad (internal/modules/cjs/loader.js:539:12) 
[Error]     at Function.Module._load (internal/modules/cjs/loader.js:531:3) 
[Error]     at Module.require (internal/modules/cjs/loader.js:637:17) 
[Error]     at require (internal/modules/cjs/helpers.js:22:18) 
[Error]     at G:\2019\Aurelia-TS-Wallaby\xcell-client-v2-jasmine\node_modules\jasmine\lib\jasmine.js:89:5 
[Error]     at Array.forEach (<anonymous>) 
[Error]     at Jasmine.loadSpecs (G:\2019\Aurelia-TS-Wallaby\xcell-client-v2-jasmine\node_modules\jasmine\lib\jasmine.js:88:18) 
[Error]     at Jasmine.execute (G:\2019\Aurelia-TS-Wallaby\xcell-client-v2-jasmine\node_modules\jasmine\lib\jasmine.js:259:8) 
[Error]     at WebSocket.emit (events.js:189:13) 
[Error]     at afterWrite (_stream_writable.js:480:3) 
[Error]     at onwrite (_stream_writable.js:471:7) 
[Error]     at InflateRaw.afterTransform (_stream_transform.js:94:3) 
[Error]     at Zlib.processCallback (zlib.js:626:8) 
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [yqvg9] Run 0 test(s), skipped 0 test(s)
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers [yqvg9] Sandbox is responsive, closing it
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:workers Merging parallel test run results
[Info]  Finished executing 10 affected test(s)
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:project Test run finished
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:project Processed console.log entries
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:project Processed loading sequences
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:project Processed executed tests
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:project Processed code coverage
[Info]  Sun, 07 Jul 2019 01:30:20 GMT wallaby:project Test run result processed and sent to IDE

So, I am not sure exactly you’re suggesting here.
I know the setup function is commented out, but I don’t think you mean to uncomment the chai plugin as chai is not installed.

So that means, I think, that you are suggesting to import the polyfill there?
I don’t think that is required as the wallaby debug log seems to show the setup.ts is being called.

Am I missing something else? I could be as the post was me not knowing what to do.

1 Like

Thanks for putting that together.

I am sure it will help someone, but since it uses another loader with a different setup requirement I couldn’t figure out what would apply in my TS/Alameda project.

1 Like

Actually what @huochunpeng said is the issue. You need to import aurelia-polyfills soon enough. So my proposal was trying to do so in the commented Setup function

1 Like

This is my wallaby.js which works great with alameda and typescript

module.exports = function (wallaby) {
    wallaby.defaults.files.instrument = true;
    wallaby.defaults.tests.instrument = true;
    return {
      files: [
        {pattern: 'src/**/*.ts', instrument: true},          
          'src/**/*.html',
          'test/unit/**/__snapshots__/*.snap',
          'tsconfig.json',
          'test/jest-pretest.ts'          
        ],

        tests: [
          'test/unit/**/*.spec.ts'
        ],

        compilers: {
          '**/*.ts': wallaby.compilers.typeScript({
            module: 'commonjs'
          })
        },

        env: {
          type: 'node',
          runner: 'node'
        },

        testFramework: 'jest' 
      };
    };

and jest-pretest.ts which works with localStorage. Note that you need to do `yarn add huochunpeng/pal-nodejs#upgrade-jsdom" to get the localStorage working

import { Options } from "aurelia-loader-nodejs";
import { globalize, initialize } from "aurelia-pal-nodejs";
import "aurelia-polyfills";
import * as path from "path";
import environment from "../src/environment";

Options.relativeToDir = path.join(__dirname, "unit");
globalize();
initialize();
environment.debug = true;
environment.testing = true;

Hope it helps

1 Like

Thanks @jeremyholt

Probably missed, but noted jest works fine in an earlier post.
Could you make a karma/jasmine typescript/alameda project and setup Wallaby to run tests to see if that works correctly for you?

1 Like

I’ve never used karma - I suppose I’m going to have to learn it eventually :grinning:

1 Like

Me either, I just used the CLI to create the project and added the Wallaby requirements to some some simple testing and look at it. Jest worked out of the box with the same setup.

Jasmine works for 10 of, I think 11 tests and raised the original post as I am far from an expert on any of the browser dev tools.

1 Like

I wish there was a clear tutorial about testing somewhere here.

So much of it seems to be “black magic”.

I spend sooooo long trying to set up tests - eventually I get it through trial and error.

Mind you, because it is so difficult, it has forced me to rethink the way I write an app.

I put all the complicated business logic that doesn’t depend on httpClient in a separate service, and test that alone. I will then inject that service into the service that depends on httpClient, so I don’t have to worry about mocking httpClient (which I still haven’t worked out how to do).

It’s easy enough to physically check that the the fetch-client is getting the data back from the server just by running the app, so I just concentrate on the business logic.

Also because Wallaby is so harsh :slight_smile: it helps enormously to identify problems when setting up the tests.

My other major problem is that I just can’t get to grips with mocking in jest. I’ve read the docs dozens of time, but still don’t “get it”. I guess I’ll have to spend more time on this.

You have no idea how long it took me to work this setup out! I ended up looking at other projects where I found jest.useFakeTimers();. I still don’t know what it does - but if it’s not there it doesn’t work!

describe("FetchService getUrl(params)", () => {
  beforeEach(() => {
    jest.useFakeTimers();
    const initialState = new CreateState().create();
    store = new Store<IState>(initialState);
    auContainer.registerInstance(Store, store);
    auContainer.registerInstance(HttpClient, http);
    auth = auContainer.get(AuthenticationService);
    sut = auContainer.get(MockFetchService) as MockFetchService;
    queryCulture = `culture=${auth.culture}`;
  });

  afterEach(() => {
    jest.clearAllTimers();
  });
1 Like

Can you open up a new topic with depicting individual issues you’ve been facing with testing. Compared to other frameworks Aurelia so far has been a joy to Test. Testing JS, especially heavily modularized and FRP oriented Code is generally not easy, unrelated to the frameworks. So lets see your concrete use cases and we can might come up with a sort of cookbook for the docs

1 Like

Faketimers from jest essentially Mock all settimeout calls, so the effect of that is that no macro task is triggered which perhaps causes your sideeffects

1 Like