wallabyjs / public

Repository for Wallaby.js questions and issues
http://wallabyjs.com
758 stars 45 forks source link

Wallaby reports false positive failure on jest test #2221

Closed maplion closed 4 years ago

maplion commented 4 years ago

Issue description or question

I am attempting to create tests for redux-observable epics within Angular, utilizing Jest 24.9.0. While I have struggled to figure out the proper way to mock dependencies and get the setup right, I finally got something working that works in Jest, but Wallaby shows me pink squares (but no red squares), starting with spectator_AppService = createService_AppService() in my beforeEach() function. If there is some insightful information the testing gurus could share with me, that would be nice, but here is my describe setup; the pink squares start with the first beforeEach declaration (and my entire test is pink squares except the "it" line):

describe('Epics: WebSocketEpics', () => {
    let spectator_EnvService: SpectatorService<EnvService>;
    const createService_EnvService = createServiceFactory({
        service: EnvService,
        providers: [],
        entryComponents: [],
        mocks: [],
    });
    let spectator_AppService: SpectatorService<AppService>;
    const createService_AppService = createServiceFactory({
        service: AppService,
        providers: [],
        entryComponents: [],
        mocks: [FeatureFlagService, NgRedux as any],
    });
    let spectator_LoggingService: SpectatorService<LoggingService>;
    const createService_LoggingService = createServiceFactory({
        service: LoggingService,
        providers: [],
        entryComponents: [],
        mocks: [],
    });
    // @ts-ignore
    const createService_WebSocketEpics = createServiceFactory({
        service: WebSocketEpics,
        providers: [],
        entryComponents: [],
        mocks: [EnvService, LoggingService, AppService],
    });
    let webSocketEpics: WebSocketEpics;

    beforeEach(() => {
        spectator_AppService = createService_AppService();
        spectator_LoggingService = createService_LoggingService();
        spectator_EnvService = createService_EnvService();
        webSocketEpics = new WebSocketEpics(
            spectator_EnvService.service,
            spectator_AppService.service,
            spectator_LoggingService.service
        );
        webSocketEpics.webSocketSubject = new WebSocketSubject<{}>('http://fake.url');
    });

    it('should correctly call `PING` on WebSocket', fakeAsync(() => {
        const type = 'WEBSOCKET::PING';
        const action$ = of({ type });
        const epic$ = webSocketEpics.pingMessageEpic(action$);

        epic$.subscribe((action: AnyAction) => {
            // console.log(action);
            expect(action.type).toBe('WEBSOCKET::PING_MESSAGE_SENT');
            expect(action.payload).toEqual({action: 'ping'});
            tick(100);
        });
    }));
}

Wallaby diagnostics report

{
  editorVersion: '1.38.1',
  pluginVersion: '1.0.143',
  editorType: 'VSCode',
  osVersion: 'win32 10.0.18362',
  nodeVersion: 'v12.3.1',
  coreVersion: '1.0.755',
  config: {
    files: [
      { pattern: 'tsconfig.json', ignore: false, trigger: true, load: true, instrument: true, order: 1 },
      { pattern: 'tsconfig.spec.json', ignore: false, trigger: true, load: true, instrument: true, order: 2 },
      { pattern: 'jest.config.js', ignore: false, trigger: true, load: true, instrument: true, order: 3 },
      { pattern: 'src/**/*.+(ts|html|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)', ignore: false, trigger: true, load: true, instrument: true, order: 4 },
      { pattern: '**/*.spec.ts', ignore: true, trigger: true, load: true, instrument: true },
      { pattern: '**/node_modules/**/*', ignore: true, trigger: true, load: true, instrument: true },
      { pattern: '**/dist/**/*', ignore: true, trigger: true, load: true, instrument: true },
      { pattern: '**/*.spec.ts.snap', ignore: false, instrument: false, trigger: true, load: true, order: 5 },
      { pattern: '**/node_modules/**/*.snap', ignore: true, instrument: false, trigger: true, load: true },
      { pattern: '**/dist/**/*.snap', ignore: true, instrument: false, trigger: true, load: true },
      { pattern: 'package.json', ignore: false, instrument: false, trigger: true, load: true, order: 6 }
    ],
    tests: [
      { pattern: '**/*.spec.ts', ignore: false, trigger: true, load: true, test: true, order: 7 },
      { pattern: '**/node_modules/**/*', ignore: true, trigger: true, load: true, test: true },
      { pattern: '**/dist/**/*', ignore: true, trigger: true, load: true, test: true }
    ],
    env: { type: 'node', runner: 'node', params: {}, viewportSize: { width: 800, height: 600 }, options: { width: 800, height: 600 }, bundle: true },
    compilers: { '**/*.?(lit)coffee?(.md)': [Function] },
    preprocessors: { 'src/**/*.component.ts': [Function: ngxWallabyJest], 'package.json': [Function] },
    testFramework: { version: 'jest@0.4.3', configurator: 'jest@0.4.3', reporter: 'jest@0.4.3', starter: 'jest@0.4.3' },
    debug: false,
    diagnostics: {},
    filesWithNoCoverageCalculated: [],
    runAllTestsInAffectedTestFile: false,
    maxConsoleMessagesPerTest: 100,
    autoConsoleLog: true,
    delays: { run: 0, edit: 100, update: 0 },
    workers: { initial: 0, regular: 0, recycle: false },
    teardown: undefined,
    hints: {
      ignoreCoverage: '__REGEXP /ignore coverage|istanbul ignore/',
      ignoreCoverageForFile: '__REGEXP /ignore file coverage/',
      commentAutoLog: '?',
      testFileSelection: { include: '__REGEXP /file\\.only/', exclude: '__REGEXP /file\\.skip/' }
    },
    automaticTestFileSelection: true,
    runSelectedTestsOnly: false,
    extensions: {},
    reportUnhandledPromises: true,
    slowTestThreshold: 75,
    lowCoverageThreshold: 80,
    loose: true,
    configCode: "const ngxWallabyJest = require('ngx-wallaby-jest');\r" +
      '\n\r' +
      '\nmodule.exports = function (wallaby) {\r' +
      '\n    return {\r' +
      '\n        files: [\r' +
      "\n            'tsconfig.json',\r" +
      "\n            'tsconfig.spec.json',\r" +
      "\n            'jest.config.js',\r" +
      "\n            'src/**/*.+(ts|html|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)',\r" +
      "\n            '!**/*.spec.ts',\r" +
      "\n            '!**/node_modules/**/*',\r" +
      "\n            '!**/dist/**/*',\r" +
      '\n        ],\r' +
      '\n\r' +
      '\n        tests: [\r' +
      "\n            '**/*.spec.ts',\r" +
      "\n            '!**/node_modules/**/*',\r" +
      "\n            '!**/dist/**/*',\r" +
      '\n        ],\r' +
      '\n\r' +
      '\n        env: {\r' +
      "\n            type: 'node',\r" +
      "\n            runner: 'node'\r" +
      '\n        },\r' +
      '\n        compilers: {\r' +
      "\n            '**/*.ts?(x)': wallaby.compilers.typeScript({\r" +
      "\n                module: 'commonjs',\r" +
      '\n                getCustomTransformers: () => {\r' +
      '\n                    return {\r' +
      '\n                        before: [\r' +
      "\n                            require('jest-preset-angular/InlineHtmlStripStylesTransformer').factory(\r" +
      "\n                                { compilerModule: require('typescript') }\r" +
      '\n                            )\r' +
      '\n                        ]\r' +
      '\n                    };\r' +
      '\n                }\r' +
      '\n            }),\r' +
      '\n        },\r' +
      '\n        setup: function (wallaby) {\r' +
      "\n            const jestConfig = require('./jest.config.js');\r" +
      "\n            jestConfig.transform = { '^.+\\\\.(ts)$': 'ts-jest' };\r" +
      '\n            // Map our path aliases.\r' +
      '\n            Object.keys(jestConfig.moduleNameMapper).forEach(\r' +
      '\n                k =>\r' +
      '\n                    (jestConfig.moduleNameMapper[k] = jestConfig.moduleNameMapper[k].replace(\r' +
      "\n                        '<rootDir>',\r" +
      '\n                        wallaby.localProjectDir\r' +
      '\n                    ))\r' +
      '\n            );\r' +
      '\n            wallaby.testFramework.configure(jestConfig);\r' +
      '\n        },\r' +
      '\n        preprocessors: {\r' +
      "\n            'src/**/*.component.ts': ngxWallabyJest\r" +
      '\n        },\r' +
      '\n\r' +
      '\n        // hints: {\r' +
      '\n        //     allowIgnoringCoverageInTests: true,\r' +
      '\n        //     ignoreCoverage: /ignore coverage/\r' +
      '\n        // },\r' +
      '\n\r' +
      "\n        testFramework: 'jest',\r" +
      '\n\r' +
      '\n        debug: false\r' +
      '\n    };\r' +
      '\n};'
  },
  packageJSON: {
    dependencies: {
      '@angular-redux/form': '10.0.0',
      '@angular-redux/router': '10.0.0',
      '@angular-redux/store': '10.0.0',
      '@angular/animations': '8.2.6',
      '@angular/common': '8.2.6',
      '@angular/compiler': '8.2.6',
      '@angular/core': '8.2.6',
      '@angular/forms': '8.2.6',
      '@angular/platform-browser': '8.2.6',
      '@angular/platform-browser-dynamic': '8.2.6',
      '@angular/pwa': '0.803.4',
      '@angular/router': '8.2.6',
      '@angular/service-worker': '8.2.6',
      '@ng-bootstrap/ng-bootstrap': '5.1.1',
      'angular-font-awesome': '3.1.2',
      'angular-oauth2-oidc': '8.0.4',
      'arcgis-js-api': '4.12.1',
      bootstrap: '4.3.1',
      'core-js': '3.2.1',
      'esri-loader': '2.10.0',
      'font-awesome': '4.7.0',
      'graphql-tag': '2.10.1',
      hammerjs: '2.0.8',
      immutable: '4.0.0-rc.12',
      lodash: '4.17.15',
      moment: '2.24.0',
      'ngx-mask': '8.0.5',
      pannellum: '2.5.4',
      redux: '4.0.4',
      'redux-logger': '3.0.6',
      'redux-observable-es6-compat': '^1.2.1',
      rxjs: '6.5.3',
      'zone.js': '0.10.2'
    },
    devDependencies: {
      '@angular-builders/jest': '8.2.0',
      '@angular-devkit/build-angular': '0.803.4',
      '@angular/cli': '8.3.4',
      '@angular/compiler-cli': '8.2.6',
      '@angular/language-service': '8.2.6',
      '@fortawesome/fontawesome-pro': '5.10.2',
      '@ngneat/spectator': '4.2.2',
      '@types/arcgis-js-api': '4.12.0',
      '@types/jasmine': '3.4.0',
      '@types/jasminewd2': '2.0.6',
      '@types/jest': '24.0.18',
      '@types/moment': '2.13.0',
      '@types/node': '12.7.5',
      '@types/redux-logger': '3.0.7',
      'aws-sdk': '2.528.0',
      canvas: '2.6.0',
      chromedriver: '76.0.0',
      'chromedriver-version-matcher': '1.0.0-alpha.4',
      codelyzer: '5.1.0',
      'eslint-plugin-jest': '22.17.0',
      'eslint-plugin-jest-formatting': '1.1.0',
      'jasmine-core': '3.4.0',
      'jasmine-spec-reporter': '4.2.1',
      jest: '24.9.0',
      'jest-extended': '0.11.2',
      'jest-module-name-mapper': '0.1.2',
      'jest-preset-angular': '7.1.1',
      'jest-sonar-reporter': '2.0.0',
      'json-server': '0.15.1',
      mockdate: '2.0.5',
      'ngx-wallaby-jest': '0.0.2',
      protractor: '5.4.2',
      'protractor-image-comparison': '3.4.0',
      puppeteer: '1.17.0',
      'redux-devtools-extension': '2.13.8',
      serverless: '1.52.0',
      'serverless-cf-vars': '0.3.2',
      'serverless-offline': '5.11.0',
      'serverless-plugin-tracing': '2.0.0',
      shelljs: '0.8.3',
      sinon: '^7.5.0',
      'ts-node': '8.4.1',
      'tsconfig-paths-jest': '0.0.1',
      tslint: '5.20.0',
      typescript: '3.5.3'
    }
  },
  fs: { numberOfFiles: 352 },
  debug: [
    '2019-09-26T05:19:04.804Z project Wallaby Node version: v12.3.1\n',
    '2019-09-26T05:19:04.804Z project Wallaby config: C:\\git\\geocomm\\gc-maps-frontend\\wallaby.js\n',
    '2019-09-26T05:19:07.083Z fs File system scan has finished by timeout\n',
    '2019-09-26T05:19:07.091Z project File cache: C:\\Users\\ryand\\.vscode\\extensions\\wallabyjs.wallaby-vscode-1.0.143\\projects\\868611a219a33db6\n',
    '2019-09-26T05:19:07.135Z uiService Listening port 51235\n',
    '2019-09-26T05:19:07.184Z workers Parallelism for initial run: 14, for regular run: 7\n',
    '2019-09-26T05:19:07.185Z workers Starting run worker instance #0\n',
    '2019-09-26T05:19:07.185Z workers Starting run worker instance #1\n',
    '2019-09-26T05:19:07.185Z workers Starting run worker instance #2\n',
    '2019-09-26T05:19:07.185Z workers Starting run worker instance #3\n',
    '2019-09-26T05:19:07.185Z workers Starting run worker instance #4\n',
    '2019-09-26T05:19:07.185Z workers Starting run worker instance #5\n',
    '2019-09-26T05:19:07.185Z workers Starting run worker instance #6\n',
    '2019-09-26T05:19:07.185Z workers Starting run worker instance #7\n',
    '2019-09-26T05:19:07.185Z workers Starting run worker instance #8\n',
    '2019-09-26T05:19:07.185Z workers Starting run worker instance #9\n',
    '2019-09-26T05:19:07.185Z workers Starting run worker instance #10\n',
    '2019-09-26T05:19:07.185Z workers Starting run worker instance #11\n',
    '2019-09-26T05:19:07.185Z workers Starting run worker instance #12\n',
    '2019-09-26T05:19:07.185Z workers Starting run worker instance #13\n',
    '2019-09-26T05:19:07.193Z workers Web server is listening at 65029\n',
    '2019-09-26T05:19:07.647Z workers Started run worker instance (delayed) #0\n',
    '2019-09-26T05:19:07.648Z workers Started run worker instance (delayed) #1\n',
    '2019-09-26T05:19:07.648Z workers Started run worker instance (delayed) #2\n',
    '2019-09-26T05:19:07.651Z project File cache requires some updates, waiting required files from IDE\n',
    '2019-09-26T05:19:07.653Z workers Started run worker instance (delayed) #3\n',
    '2019-09-26T05:19:07.653Z workers Started run worker instance (delayed) #4\n',
    '2019-09-26T05:19:07.675Z extended-core New document or complex document change\n',
    '2019-09-26T05:19:07.677Z workers Started run worker instance (delayed) #5\n',
    '2019-09-26T05:19:08.104Z workers Started run worker instance (delayed) #6\n',
    '2019-09-26T05:19:08.105Z workers Started run worker instance (delayed) #9\n',
    '2019-09-26T05:19:08.106Z workers Started run worker instance (delayed) #8\n',
    '2019-09-26T05:19:08.106Z workers Started run worker instance (delayed) #7\n',
    '2019-09-26T05:19:08.106Z workers Started run worker instance (delayed) #10\n',
    '2019-09-26T05:19:08.107Z workers Started run worker instance (delayed) #12\n',
    '2019-09-26T05:19:08.107Z workers Started run worker instance (delayed) #11\n',
    '2019-09-26T05:19:08.107Z workers Started run worker instance (delayed) #13\n',
    '2019-09-26T05:19:08.304Z project Stopping process pool\n',
    '2019-09-26T05:19:08.307Z project Running postprocessor\n',
    '2019-09-26T05:19:08.323Z postprocessor New TypeScript language service is required\n',
    '2019-09-26T05:19:11.151Z project Re-attaching document block comment\n',
    '2019-09-26T05:19:11.189Z project Re-attaching document block comment\n',
    '2019-09-26T05:19:11.189Z project Re-attaching document block comment\n',
    '2019-09-26T05:19:11.198Z project Re-attaching document block comment\n',
    '2019-09-26T05:19:11.327Z project Postprocessor execution finished\n',
    '2019-09-26T05:19:11.327Z project Test run started; run priority: 3\n',
    '2019-09-26T05:19:11.327Z project Running all tests\n',
    '2019-09-26T05:19:11.334Z workers Starting test run, priority: 3\n',
    '2019-09-26T05:19:11.334Z workers Distributing tests between 14 workers\n',
    '2019-09-26T05:19:11.334Z workers Running tests in parallel\n',
    '2019-09-26T05:19:11.334Z nodeRunner Starting sandbox [worker #0, session #jgcam]\n',
    '2019-09-26T05:19:11.334Z nodeRunner Starting sandbox [worker #1, session #wbxop]\n',
    '2019-09-26T05:19:11.334Z nodeRunner Starting sandbox [worker #2, session #23o0v]\n',
    '2019-09-26T05:19:11.334Z nodeRunner Starting sandbox [worker #3, session #5cuku]\n',
    '2019-09-26T05:19:11.334Z nodeRunner Starting sandbox [worker #4, session #hmpef]\n',
    '2019-09-26T05:19:11.334Z nodeRunner Starting sandbox [worker #5, session #kfgdz]\n',
    '2019-09-26T05:19:11.334Z nodeRunner Starting sandbox [worker #6, session #18n38]\n',
    '2019-09-26T05:19:11.335Z nodeRunner Preparing sandbox [worker #0, session #jgcam]\n',
    '2019-09-26T05:19:11.335Z nodeRunner Preparing sandbox [worker #1, session #wbxop]\n',
    '2019-09-26T05:19:11.335Z nodeRunner Preparing sandbox [worker #2, session #23o0v]\n',
    '2019-09-26T05:19:11.335Z nodeRunner Preparing sandbox [worker #3, session #5cuku]\n',
    '2019-09-26T05:19:11.335Z nodeRunner Preparing sandbox [worker #4, session #hmpef]\n',
    '2019-09-26T05:19:11.335Z nodeRunner Preparing sandbox [worker #5, session #kfgdz]\n',
    '2019-09-26T05:19:11.335Z nodeRunner Preparing sandbox [worker #6, session #18n38]\n',
    '2019-09-26T05:19:11.335Z nodeRunner Prepared sandbox [worker #0, session #jgcam]\n',
    '2019-09-26T05:19:11.335Z nodeRunner Prepared sandbox [worker #1, session #wbxop]\n',
    '2019-09-26T05:19:11.335Z nodeRunner Prepared sandbox [worker #2, session #23o0v]\n',
    '2019-09-26T05:19:11.335Z nodeRunner Prepared sandbox [worker #3, session #5cuku]\n',
    '2019-09-26T05:19:11.335Z nodeRunner Prepared sandbox [worker #4, session #hmpef]\n',
    '2019-09-26T05:19:11.335Z nodeRunner Prepared sandbox [worker #5, session #kfgdz]\n',
    '2019-09-26T05:19:11.335Z nodeRunner Prepared sandbox [worker #6, session #18n38]\n',
    '2019-09-26T05:19:11.335Z workers [worker #0, session #jgcam] Running tests in sandbox\n',
    '2019-09-26T05:19:11.336Z workers [worker #1, session #wbxop] Running tests in sandbox\n',
    '2019-09-26T05:19:11.336Z workers [worker #2, session #23o0v] Running tests in sandbox\n',
    '2019-09-26T05:19:11.337Z workers [worker #3, session #5cuku] Running tests in sandbox\n',
    '2019-09-26T05:19:11.337Z workers [worker #4, session #hmpef] Running tests in sandbox\n',
    '2019-09-26T05:19:11.337Z workers [worker #5, session #kfgdz] Running tests in sandbox\n',
    '2019-09-26T05:19:11.337Z workers [worker #6, session #18n38] Running tests in sandbox\n',
    '2019-09-26T05:19:15.326Z workers [jgcam] Loaded unknown number of test(s)\n',
    '2019-09-26T05:19:15.326Z workers [jgcam] Test executed: test placeholder\n',
    '2019-09-26T05:19:15.327Z workers [hmpef] Loaded unknown number of test(s)\n',
    '2019-09-26T05:19:15.328Z workers [hmpef] Test executed: temporary time placeholder\n',
    '2019-09-26T05:19:15.377Z workers [kfgdz] Loaded unknown number of test(s)\n',
    '2019-09-26T05:19:15.377Z workers [jgcam] Run 1 test(s), skipped 0 test(s)\n',
    '2019-09-26T05:19:15.377Z workers [kfgdz] Test executed: should be created\n',
    '2019-09-26T05:19:15.378Z workers [hmpef] Run 1 test(s), skipped 0 test(s)\n',
    '2019-09-26T05:19:15.378Z workers [jgcam] Sandbox is responsive, closing it\n',
    '2019-09-26T05:19:15.379Z workers [hmpef] Sandbox is responsive, closing it\n',
    '2019-09-26T05:19:15.417Z workers [kfgdz] Run 1 test(s), skipped 0 test(s)\n',
    '2019-09-26T05:19:15.418Z workers [kfgdz] Sandbox is responsive, closing it\n',
    '2019-09-26T05:19:15.739Z workers [23o0v] Loaded unknown number of test(s)\n',
    '2019-09-26T05:19:15.739Z workers [23o0v] Test executed: exists\n',
    '2019-09-26T05:19:15.775Z workers [23o0v] Run 1 test(s), skipped 0 test(s)\n',
    '2019-09-26T05:19:15.776Z workers [23o0v] Sandbox is responsive, closing it\n',
    '2019-09-26T05:19:15.861Z workers [5cuku] Loaded unknown number of test(s)\n',
    '2019-09-26T05:19:15.861Z workers [5cuku] Test executed: exists\n',
    '2019-09-26T05:19:15.862Z workers [5cuku] Test executed: Subject: it checks comboBox items are emitting\n',
    '2019-09-26T05:19:15.862Z workers [5cuku] Test executed: Subject: it checks comboBox Blur is emitting\n',
    '2019-09-26T05:19:15.862Z workers [5cuku] Test executed: Subject: it checks status button items are emitting\n',
    '2019-09-26T05:19:15.862Z workers [5cuku] Test executed: Subject: it checks status button form items are emitting\n',
    '2019-09-26T05:19:15.863Z workers [5cuku] Test executed: Subject: it checks save button form items are emitting\n',
    '2019-09-26T05:19:15.877Z workers [wbxop] Loaded unknown number of test(s)\n',
    '2019-09-26T05:19:15.895Z workers [wbxop] Test executed: should create\n',
    '2019-09-26T05:19:15.902Z workers [5cuku] Run 6 test(s), skipped 0 test(s)\n',
    '2019-09-26T05:19:15.903Z workers [5cuku] Sandbox is responsive, closing it\n',
    '2019-09-26T05:19:15.910Z workers [wbxop] Test executed: basemap has a default value\n',
    '2019-09-26T05:19:15.920Z workers [wbxop] Test executed: center has a default value\n',
    '2019-09-26T05:19:15.920Z workers [wbxop] Test executed: zoom has a default value\n',
    '2019-09-26T05:19:15.955Z workers [wbxop] Run 4 test(s), skipped 0 test(s)\n',
    '2019-09-26T05:19:15.956Z workers [wbxop] Sandbox is responsive, closing it\n',
    '2019-09-26T05:19:16.543Z workers [18n38] Loaded unknown number of test(s)\n',
    '2019-09-26T05:19:16.543Z workers [18n38] Test executed: should correctly call `PING` on WebSocket\n',
    '2019-09-26T05:19:16.544Z workers Failed to map the stack to user code, entry message: Error: 1 timer(s) still in the queue., stack: Error: 1 timer(s) still in the ' +
      'queue.\n    at C:\\git\\geocomm\\gc-maps-frontend\\node_modules\\zone.js\\dist\\fake-async-test.js:596:31\n    at ZoneDelegate.invoke ' +
      '(C:\\git\\geocomm\\gc-maps-frontend\\node_modules\\zone.js\\dist\\zone.js:396:30)\n    at ProxyZoneSpec.onInvoke ' +
      '(C:\\git\\geocomm\\gc-maps-frontend\\node_modules\\zone.js\\dist\\proxy.js:117:43)\n    at ZoneDelegate.invoke ' +
      '(C:\\git\\geocomm\\gc-maps-frontend\\node_modules\\zone.js\\dist\\zone.js:395:36)\n    at Zone.run (C:\\git\\geocomm\\gc-maps-frontend\\node_modules\\zone.js\\dist\\zone.js:153:47)\n ' +
      '   at Object.<anonymous> (C:\\git\\geocomm\\gc-maps-frontend\\node_modules\\jest-preset-angular\\zone-patch\\index.js:52:27)\n    at Object.e.length.arguments.<computed> ' +
      '(c:\\Users\\ryand\\.vscode\\extensions\\wallabyjs.wallaby-vscode-1.0.143\\wallaby\\runners\\node\\jest@0.4.3\\jasmine2Initializer.js:14:1786)\n    at Object.asyncJestTest ' +
      '(C:\\git\\geocomm\\gc-maps-frontend\\node_modules\\jest-jasmine2\\build\\jasmineAsyncInstall.js:102:37)\n    at ' +
      'C:\\git\\geocomm\\gc-maps-frontend\\node_modules\\jest-jasmine2\\build\\qu\n',
    "2019-09-26T05:19:16.544Z workers Failed to map the stack to user code, entry message: TypeError: Cannot read property 'pipe' of undefined, stack: TypeError: Cannot read " +
      "property 'pipe' of undefined\n    at new AppService (C:\\git\\geocomm\\gc-maps-frontend\\src\\app\\core\\services\\app.service.ts:24:14)\n    at " +
      'C:\\git\\geocomm\\packages\\core\\src\\di\\util.ts:53:18\n    at _callFactory (C:\\git\\geocomm\\packages\\core\\src\\view\\ng_module.ts:194:14)\n    at _createProviderInstance ' +
      '(C:\\git\\geocomm\\packages\\core\\src\\view\\ng_module.ts:147:20)\n    at resolveNgModuleDep (C:\\git\\geocomm\\packages\\core\\src\\view\\ng_module.ts:121:15)\n    at _createClass ' +
      '(C:\\git\\geocomm\\packages\\core\\src\\view\\ng_module.ts:179:50)\n    at _createProviderInstance (C:\\git\\geocomm\\packages\\core\\src\\view\\ng_module.ts:144:20)\n    at ' +
      'resolveNgModuleDep (C:\\git\\geocomm\\packages\\core\\src\\view\\ng_module.ts:106:13)\n    at NgModuleRef_.get (C:\\git\\geocomm\\packages\\core\\src\\view\\refs.ts:507:12)\n    at ' +
      'TestBedViewEngine.get (C:\\git\\packages\\core\\testing\\src\\test_bed.ts:470:45)\n    at Function.TestBedViewEngine.get (C:\\git\\packages\\core\\testing\\src\\test_bed.ts:228:36)\n ' +
      '   at C:\\git\\geocomm\\gc-maps-frontend\\node_modu\n',
    '2019-09-26T05:19:16.581Z workers [18n38] Run 1 test(s), skipped 0 test(s)\n',
    '2019-09-26T05:19:16.582Z workers [18n38] Sandbox is responsive, closing it\n',
    '2019-09-26T05:19:16.582Z workers Merging parallel test run results\n',
    '2019-09-26T05:19:16.591Z project Test run finished\n',
    '2019-09-26T05:19:16.592Z project Processed console.log entries\n',
    '2019-09-26T05:19:16.592Z project Processed loading sequences\n',
    '2019-09-26T05:19:16.593Z project Processed executed tests\n',
    '2019-09-26T05:19:16.599Z project Processed code coverage\n',
    '2019-09-26T05:19:16.638Z project Test run result processed and sent to IDE\n',
    '2019-09-26T05:19:39.717Z fs File changed in editor: src/app/shared/websocket/epics/websocket.epics.spec.ts\n',
    '2019-09-26T05:19:39.733Z project Running postprocessor\n',
    '2019-09-26T05:19:39.733Z testTask Test files from affected: 1, from deleted or manually requested: 0, from recently changed: 0, from loaded by: 0, from failing: 0\n',
    '2019-09-26T05:19:39.905Z project Detected single test [should correctly call `PING` on WebSocket] change\n',
    '2019-09-26T05:19:39.910Z project Postprocessor execution finished\n',
    '2019-09-26T05:19:39.910Z project Test run started; run priority: 2\n',
    '2019-09-26T05:19:39.910Z testTask Test files from affected: 1, from deleted or manually requested: 0, from recently changed: 0, from loaded by: 0, from failing: 0\n',
    '2019-09-26T05:19:39.917Z workers Starting test run, priority: 2\n',
    '2019-09-26T05:19:39.917Z nodeRunner Starting sandbox [worker #0, session #k3n0d]\n',
    '2019-09-26T05:19:39.917Z nodeRunner Preparing sandbox [worker #0, session #k3n0d]\n',
    '2019-09-26T05:19:39.917Z nodeRunner Prepared sandbox [worker #0, session #k3n0d]\n',
    '2019-09-26T05:19:39.917Z workers [worker #0, session #k3n0d] Running tests in sandbox\n',
    '2019-09-26T05:19:41.310Z workers [k3n0d] Loaded unknown number of test(s)\n',
    '2019-09-26T05:19:41.310Z workers [k3n0d] Test executed: should correctly call `PING` on WebSocket\n',
    "2019-09-26T05:19:41.311Z workers Failed to map the stack to user code, entry message: TypeError: Cannot read property 'pipe' of undefined, stack: TypeError: Cannot read " +
      "property 'pipe' of undefined\n    at new AppService (C:\\git\\geocomm\\gc-maps-frontend\\src\\app\\core\\services\\app.service.ts:24:14)\n    at " +
      'C:\\git\\geocomm\\packages\\core\\src\\di\\util.ts:53:18\n    at _callFactory (C:\\git\\geocomm\\packages\\core\\src\\view\\ng_module.ts:194:14)\n    at _createProviderInstance ' +
      '(C:\\git\\geocomm\\packages\\core\\src\\view\\ng_module.ts:147:20)\n    at resolveNgModuleDep (C:\\git\\geocomm\\packages\\core\\src\\view\\ng_module.ts:121:15)\n    at _createClass ' +
      '(C:\\git\\geocomm\\packages\\core\\src\\view\\ng_module.ts:179:50)\n    at _createProviderInstance (C:\\git\\geocomm\\packages\\core\\src\\view\\ng_module.ts:144:20)\n    at ' +
      'resolveNgModuleDep (C:\\git\\geocomm\\packages\\core\\src\\view\\ng_module.ts:106:13)\n    at NgModuleRef_.get (C:\\git\\geocomm\\packages\\core\\src\\view\\refs.ts:507:12)\n    at ' +
      'TestBedViewEngine.get (C:\\git\\packages\\core\\testing\\src\\test_bed.ts:470:45)\n    at Function.TestBedViewEngine.get (C:\\git\\packages\\core\\testing\\src\\test_bed.ts:228:36)\n ' +
      '   at C:\\git\\geocomm\\gc-maps-frontend\\node_modu\n',
    '2019-09-26T05:19:41.340Z workers [k3n0d] Run 1 test(s), skipped 0 test(s)\n',
    '2019-09-26T05:19:41.341Z workers [k3n0d] Sandbox is responsive, closing it\n',
    '2019-09-26T05:19:41.341Z project Test run finished\n',
    '2019-09-26T05:19:41.341Z project Processed console.log entries\n',
    '2019-09-26T05:19:41.341Z project Processed loading sequences\n',
    '2019-09-26T05:19:41.342Z project Processed executed tests\n',
    '2019-09-26T05:19:41.346Z project Processed code coverage\n',
    '2019-09-26T05:19:41.351Z project Test run result processed and sent to IDE\n',
    '2019-09-26T05:19:41.608Z fs File changed: src/app/shared/websocket/epics/websocket.epics.spec.ts\n',
    '2019-09-26T05:19:41.633Z fs No changes detected for src/app/shared/websocket/epics/websocket.epics.spec.ts\n',
    '2019-09-26T05:19:41.633Z extended-core File was not changed, but file markers may need to be synced\n'
  ]
}
ArtemGovorov commented 4 years ago

It looks like there's some issue with the

it('should correctly call `PING` on WebSocket', fakeAsync(() => {
        const type = 'WEBSOCKET::PING';
        const action$ = of({ type });
        const epic$ = webSocketEpics.pingMessageEpic(action$);

        epic$.subscribe((action: AnyAction) => {
            // console.log(action);
            expect(action.type).toBe('WEBSOCKET::PING_MESSAGE_SENT');
            expect(action.payload).toEqual({action: 'ping'});
            tick(100);
        });
    }));

unit test. According to the provided log, the test produces 2 errors:

Error: 1 timer(s) still in the queue.

when it runs initially, and

TypeError: Cannot read property 'pipe' of undefined 
  at new AppService (C:\\git\\geocomm\\gc-maps-frontend\\src\\app\\core\\services\\app.service.ts:24:14)

on your changes inside it.

something working that works in Jest

Are you sure that your test actually works in Jest CLI? If you change your test as follows:

        epic$.subscribe((action: AnyAction) => {
            throw new Error('expected error');
            // console.log(action);
            //expect(action.type).toBe('WEBSOCKET::PING_MESSAGE_SENT');
            //expect(action.payload).toEqual({action: 'ping'});
            tick(100);
        });

does Jest display the thrown error?

Back to the errors, according to the post, this error

Error: 1 timer(s) still in the queue.

is thrown by zone.js when some “timers” (=setTimeouts) in the queue. My guess would be that your test never calls epic$.subscribe subscription action (neither in Jest nor in Wallaby, it's just that maybe Wallaby reports it, while Jest doesn't). Try something like:

        epic$.subscribe((action: AnyAction) => {
            // console.log(action);
            expect(action.type).toBe('WEBSOCKET::PING_MESSAGE_SENT');
            expect(action.payload).toEqual({action: 'ping'});
            tick(100);
        });
+       tick(1000);

If it doesn't help, or my assumptions are incorrect, please create a sample repo where we could reproduce the issue, we are happy to investigate it.

maplion commented 4 years ago

@ArtemGovorov Thank you for the response. I tried to redo my janky code to try to better isolate the problem and continue my learning process with this. I tried your suggestion and it did not make a difference. There seemed to be two main issues:

  1. I had a Service that was talking to the store via a @select() annotation, which was then reading from an observable in the constructor of that service with a .pipe(); Wallaby did not like this one bit. I was able to resolve it by wrapping the observable in a null check (not ideal to change code for tests, but this one isn't a big deal and it works!).
  2. The other issue was with another service that was not within a core module that was being loaded, but was being called within my test class, which resulted in a NullInjection error; I was able to resolve this by simply moving the file to it's appropriate location so it is part of the core module instead of a shared module. I think most is well now and this can be closed.