majestic icon indicating copy to clipboard operation
majestic copied to clipboard

Not displaying failed test

Open IPWright83 opened this issue 5 years ago • 27 comments

Is this a bug report or a feature request?

Bug: Majestic has correctly detected a failing test, however it fails to display which test is failing and the detail about it in the UI.

Version Info

  • Version of Majestic: v1.6.0
  • Version of Jest: 24.9.0
  • Version of Node: v10.16.3
  • Operating System: Windows 10x64

Reproduction Repo

I can't currently provide an example rep, but I can probably provide more debugging info.

image

IPWright83 avatar Oct 03 '19 12:10 IPWright83

it looks like the failing test is not even displayed in the UI. Probably the parser is failing to parse it properly. Does the test has any syntactical difference to other tests? Probably using .each or something else?

Raathigesh avatar Oct 04 '19 07:10 Raathigesh

The test was pretty basic, and was near identical to another test (which was passing). This one looked like this:

it('extracts affiliations correctly', () => {
        const affiliations = {
            staff: [
                {
                    type: ['Support'],
                    department: ['Foo', 'Bar'],
                },
                {
                    type: ['Academic'],
                    department: ['Foo'],
                },
            ],
        };

        const result = extractStaffAffiliations(affiliations);
        expect(result).toEqual([
            'Staff',
            'Support:Foo>Bar',
            'Academic:Foo',
        ]);
    });

There was just an execution error, jest itself handled the test and reported the error fine, as did WallabyJS.

IPWright83 avatar Oct 04 '19 13:10 IPWright83

Hello Guys, I just discovered this project, thanks for your work!

I have the same problem as described here, failing test description is not shown

GoMino avatar Oct 20 '19 18:10 GoMino

Hi! This project seems really nice! Thank you! .. But I have similar issue: If I click on "Run tests" button, it show me 4 passing suites, 38 passing tests and so on...seems it works! But if I click on the test files it not show me any details. In terminal I can see 'Determining test suites to run...' as output. Seems that he can't find the test suites..but it can run them...

I can notice a strange thing: the Project tree is composed like: {projectName} > c: > dev > ...the project path Is it ok? I would expect something like {projectName} > tests > test file and not all the absolute path..

Version of Majestic: v1.6.1 Version of Jest: 24.9.0 Version of Node: v12.3.1 Operating System: Windows 10x64

Thank you

IGionny avatar Dec 17 '19 09:12 IGionny

I did a test: if I run majestic from the Windows 10 WSL subsystem (Ubuntu) ...it works great! ...it's not the perfect solutions but for now it works!

Thank you!

IGionny avatar Dec 17 '19 11:12 IGionny

I have the same problemas @IGionny, when I launch majestic from Yarn with this command in my package.json file:

"test:unit:ui": "majestic",

I get the Majestic firing up in a browser. it correctly identifies my single unit test file and lists it under "Tests" in the left nav and it gives me the grey bar in the right panel that says the path to the test, but the number of suites it reports is 0 and the number of tests is 0, then it goes on to say 9 passing tests and 2 failing tests and it doesn't show any output below that summary bar. image

the test file I have has these properties:

  • at the file scope, it defines some variables and some variables that are functions
  • at the file scope, it defines a beforeAll and an afterAll
  • it has two describe blocks.
  • the first describe block has 8 tests using the "test" function
  • the second describe block has a beforeEach and 3 test functions

gregveres avatar Jan 31 '20 22:01 gregveres

This is the output of running jest. This is after I wrapped the entire thing in a single describe block to see if that helped with parsing:

 FAIL  src/layouts/navbar.unit.ts
  navbar tests
    creates top level menus based on user information
      √ is a Vue instance (5ms)
      √ Creates proper menues for regular user in a club with no courts (35ms)
      √ Creates proper menues for regular user in a club with one court (24ms)
      √ Creates proper menues for regular user in a club with multiple courts (27ms)
      √ Creates proper menues for user with no club membership (40ms)
      √ Creates proper menues for regular user with announcement priviledges in a club with no courts (29ms)
      √ Creates proper menues for clubAdmin in a club with no courts (17ms)
      √ Creates proper menues for siteAdmin in a club with no courts (18ms)
    view model function tests
      √ setMobileView sets the mobileView getter (28ms)
      × setMobileView emits hide-sidebar when transitioning to not mobile view from mobile view (34ms)
      × setMobileView does not emit hide-sidebar when transitioning to mobile view from not mobile view (36ms)

  ● navbar tests › view model function tests › setMobileView emits hide-sidebar when transitioning to not mobile view from mobile view

    expect(received).toHaveLength(expected)

    Matcher error: received value must have a length property whose value must be a number

    Received has value: undefined

      239 |       await wrapper.vm.$nextTick();
      240 |       // Assert
    > 241 |       expect(wrapper.emitted()['hide-sidebar']).toHaveLength(1);
          |                                                 ^
      242 |     });
      243 |     test('setMobileView does not emit hide-sidebar when transitioning to mobile view from not mobile view', async () => {
      244 |     // Arrange

      at src/layouts/navbar.unit.ts:241:49
      at fulfilled (src/layouts/navbar.unit.ts:5:58)
      at tryCallOne (node_modules/promise/lib/core.js:37:12)
      at node_modules/promise/lib/core.js:123:15
      at flush (node_modules/asap/raw.js:50:29)

  ● navbar tests › view model function tests › setMobileView does not emit hide-sidebar when transitioning to mobile view from not mobile view

    expect(received).toHaveLength(expected)

    Matcher error: received value must have a length property whose value must be a number

    Received has value: undefined

      249 |       await wrapper.vm.$nextTick();
      250 |       // Assert
    > 251 |       expect(wrapper.emitted()['hide-sidebar']).toHaveLength(0);
          |                                                 ^
      252 |     });
      253 |   });
      254 | });

      at src/layouts/navbar.unit.ts:251:49
      at fulfilled (src/layouts/navbar.unit.ts:5:58)
      at tryCallOne (node_modules/promise/lib/core.js:37:12)
      at node_modules/promise/lib/core.js:123:15
      at flush (node_modules/asap/raw.js:50:29)

  console.log src/layouts/navbar.vue:94
    menuWidth: 0, containerWidth: 0, mobileView: false

  console.log src/layouts/navbar.vue:94
    menuWidth: 0, containerWidth: 0, mobileView: false

--------------|---------|----------|---------|---------|----------------------
File          | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------|---------|----------|---------|---------|----------------------
All files     |   47.73 |    35.29 |   26.67 |   45.24 | 
 features/app |      68 |       40 |   57.14 |   65.22 | 
  appStore.ts |      68 |       40 |   57.14 |   65.22 | 35,37-39,42,44,47,48
 router       |       0 |        0 |       0 |       0 | 
  index.ts    |       0 |      100 |       0 |       0 | 1,2,4,6,17-19,29    
  routes.ts   |       0 |        0 |       0 |       0 | 3,6,8,14,15,17,21   
 store        |     100 |      100 |     100 |     100 | 
  index.ts    |     100 |      100 |     100 |     100 | 
--------------|---------|----------|---------|---------|----------------------
Test Suites: 1 failed, 1 total
Tests:       2 failed, 9 passed, 11 total
Snapshots:   0 total
Time:        13.599s
Ran all test suites.
error Command failed with exit code 1.

gregveres avatar Jan 31 '20 22:01 gregveres

Now this is interesting. I noticed that there is a --debug flag. So I ran 'majestic --app --debug' and watched the output.

When it ran within majestic, this is the output that came out:

i Executing Jest with : [                                                                                                                                                                                                                                          Jest Manager 18:01:26   
  '-r',
  '"C:\\Users\\gregv\\AppData\\Local\\Yarn\\Data\\global\\node_modules\\majestic\\dist\\server\\scripts\\patch.js"',
  '"C:\\Users\\gregv\\source\\repos\\SquashSpider\\SquashSpider\\SkyCourt.UI\\SPA\\node_modules\\jest\\bin\\jest.js"',
  '--colors',
  '--collectCoverage=false',
  '^C:.Users.gregv.source.repos.SquashSpider.SquashSpider.SkyCourt.UI.SPA.src.layouts.navbar.unit.ts$',
  '--reporters',
  'default',
  '"C:\\Users\\gregv\\AppData\\Local\\Yarn\\Data\\global\\node_modules\\majestic\\dist\\server\\scripts\\reporter.js"',
  '--verbose=false'
] {
  MAJESTIC_PORT: '4000',
  REPORT_SUMMARY: ''
}
 FAIL  src/layouts/navbar.unit.ts
  ● Console

    console.log src/layouts/navbar.vue:54
      menuWidth: 0, containerWidth: 0, mobileView: false
    console.log src/layouts/navbar.vue:54
      menuWidth: 0, containerWidth: 0, mobileView: false

  ● navbar tests › view model function tests › setMobileView emits hide-sidebar when transitioning to not mobile view from mobile view

    expect(received).toHaveLength(expected)

    Matcher error: received value must have a length property whose value must be a number

    Received has value: undefined

      239 |       await wrapper.vm.$nextTick();
      240 |       // Assert
    > 241 |       expect(wrapper.emitted()['hide-sidebar']).toHaveLength(1);
          |                                                 ^
      242 |     });
      243 |     test('setMobileView does not emit hide-sidebar when transitioning to mobile view from not mobile view', async () => {
      244 |     // Arrange

      at src/layouts/navbar.unit.ts:241:49
      at fulfilled (src/layouts/navbar.unit.ts:5:58)
      at tryCallOne (node_modules/promise/lib/core.js:37:12)
      at node_modules/promise/lib/core.js:123:15
      at flush (node_modules/asap/raw.js:50:29)

  ● navbar tests › view model function tests › setMobileView does not emit hide-sidebar when transitioning to mobile view from not mobile view

    expect(received).toHaveLength(expected)

    Matcher error: received value must have a length property whose value must be a number

    Received has value: undefined

      249 |       await wrapper.vm.$nextTick();
Determining test suites to run...i File execution start reported  C:\Users\gregv\source\repos\SquashSpider\SquashSpider\SkyCourt.UI\SPA\src\layouts\navbar.unit.ts
           Report API 18:02:29
i File result reported  C:\Users\gregv\source\repos\SquashSpider\SquashSpider\SkyCourt.UI\SPA\src\layouts\navbar.unit.ts                                                                                                                                             Report API 18:02:37

Notice that there is no summary section of which tests passed and failed. it must be the way that jest is being called. Note that there is console output. And this was picked up and displayed. So I thought I would get rid of the console output...

When I ran it again, I turned on watch and re-saved the file. No output came out, but the console output section vanished from the UI. So I started it again, clicked on my test file on the left and then clicked the run button on the far right of the test's summary bar in the right side window.

Again, no test summary was output, but there was enough information for Majestic to parse the failing tests at least:

i Executing Jest with : [                                                                                                                                                                                                                                          Jest Manager 18:07:52   
  '-r',
  '"C:\\Users\\gregv\\AppData\\Local\\Yarn\\Data\\global\\node_modules\\majestic\\dist\\server\\scripts\\patch.js"',
  '"C:\\Users\\gregv\\source\\repos\\SquashSpider\\SquashSpider\\SkyCourt.UI\\SPA\\node_modules\\jest\\bin\\jest.js"',
  '--colors',
  '--collectCoverage=false',
  '^C:.Users.gregv.source.repos.SquashSpider.SquashSpider.SkyCourt.UI.SPA.src.layouts.navbar.unit.ts$',
  '--reporters',
  'default',
  '"C:\\Users\\gregv\\AppData\\Local\\Yarn\\Data\\global\\node_modules\\majestic\\dist\\server\\scripts\\reporter.js"',
  '--verbose=false'
] {
  MAJESTIC_PORT: '4000',
  REPORT_SUMMARY: ''
}
 FAIL  src/layouts/navbar.unit.ts
  ● navbar tests › view model function tests › setMobileView emits hide-sidebar when transitioning to not mobile view from mobile view

    expect(received).toHaveLength(expected)

    Matcher error: received value must have a length property whose value must be a number

    Received has value: undefined

      239 |       await wrapper.vm.$nextTick();
      240 |       // Assert
    > 241 |       expect(wrapper.emitted()['hide-sidebar']).toHaveLength(1);
          |                                                 ^
      242 |     });
      243 |     test('setMobileView does not emit hide-sidebar when transitioning to mobile view from not mobile view', async () => {
      244 |     // Arrange

      at src/layouts/navbar.unit.ts:241:49
      at fulfilled (src/layouts/navbar.unit.ts:5:58)
      at tryCallOne (node_modules/promise/lib/core.js:37:12)
      at node_modules/promise/lib/core.js:123:15
      at flush (node_modules/asap/raw.js:50:29)

  ● navbar tests › view model function tests › setMobileView does not emit hide-sidebar when transitioning to mobile view from not mobile view

    expect(received).toHaveLength(expected)

    Matcher error: received value must have a length property whose value must be a number

    Received has value: undefined

      249 |       await wrapper.vm.$nextTick();
      250 |       // Assert
    > 251 |       expect(wrapper.emitted()['hide-sidebar']).toHaveLength(0);
          |                                                 ^
      252 |     });
      253 |   });
      254 | });

      at src/layouts/navbar.unit.ts:251:49
      at fulfilled (src/layouts/navbar.unit.ts:5:58)
      at tryCallOne (node_modules/promise/lib/core.js:37:12)
      at node_modules/promise/lib/core.js:123:15
      at flush (node_modules/asap/raw.js:50:29)

Test Suites: 1 failed, 1 total
Tests:       2 failed, 9 passed, 11 total
Snapshots:   0 total
Time:        6.43s
Ran all test suites matching /C:.Users.gregv.source.repos.SquashSpider.SquashSpider.SkyCourt.UI.SPA.src.layouts.navbar.unit.ts$/i.
i File execution start reported  C:\Users\gregv\source\repos\SquashSpider\SquashSpider\SkyCourt.UI\SPA\src\layouts\navbar.unit.ts                                                                                                                                    Report API 18:08:01
i File result reported  C:\Users\gregv\source\repos\SquashSpider\SquashSpider\SkyCourt.UI\SPA\src\layouts\navbar.unit.ts            

I do not have the button pressed to show only failed tests. I pressed the show only failed tests and ran it again. I got the same output to the debug console, but the UI still didn't show the failed tests.

gregveres avatar Jan 31 '20 23:01 gregveres

I decided to take the command line parameters that majestic was using to run jest and use them in my package.json file to run jest in the same way.

As soon as I put in the '--reporters majestic/dist/server/scripts/reporter.js' into the command, jest started to fail, saying that jest didn't exit 1 second after the commands finished. It had stack traces. I wonder if what is happening is that the custom reporter you guys are using is running for longer than a second on some machines and this causes jest to crash.

I am going to see if there is an option for lengthening that value above 1 second.

gregveres avatar Jan 31 '20 23:01 gregveres

I think we can ignore my last comment about the timeout. I looked at the error more closely and realized that in running the reporter.js, it was expecting to get the port and I hadn't set it. I set the environment variable for the port and then I re-ran it. This is what I got:

yarn run v1.19.1
$ jest --colors --collectCoverage=false --reporters 'C:\Users\gregv\AppData\Local\Yarn\Data\global\node_modules\majestic\dist\server\scripts\reporter.js'
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I had Majestic running in another window and I saw that it spit out more output when the tests ran. But I am guessing the "error command failed with exit code 1 is causing some issues. I am pretty sure it is the reporter.js that is causing the error. When I put in --reporters default <path_to_reporter.js>, then I get the expected output on the command line followed by a statement that the command failed. If I remove the reporter.js reference, then I don't get the error.

gregveres avatar Feb 01 '20 01:02 gregveres

Nope, it must be a parsing thing. I ran node and jest in a debugger and I set a break point in the reporter.js file. There were no crashes and no error command failed with exit code 1. But the post still didn't populate the tests in the UI.

Here is the body as a json object that it was about to pass to the server:

{
  "path": "C:\\Users\\gregv\\source\\repos\\SquashSpider\\SquashSpider\\SkyCourt.UI\\SPA\\src\\layouts\\navbar.unit.ts",
  "failureMessage": "\u001b[1m\u001b[31m  \u001b[1m● \u001b[22m\u001b[1mnavbar tests › view model function tests › setMobileView emits hide-sidebar when transitioning to not mobile view from mobile view\u001b[39m\u001b[22m\n\n    \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoHaveLength\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m)\u001b[22m\n\n    \u001b[1mMatcher error\u001b[22m: \u001b[31mreceived\u001b[39m value must have a length property whose value must be a number\n\n    Received has value: \u001b[31mundefined\u001b[39m\n\u001b[2m\u001b[22m\n\u001b[2m    \u001b[0m \u001b[90m 239 | \u001b[39m      await wrapper\u001b[33m.\u001b[39mvm\u001b[33m.\u001b[39m$nextTick()\u001b[33m;\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m    \u001b[0m \u001b[90m 240 | \u001b[39m      \u001b[90m// Assert\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m    \u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[2m\u001b[39m\u001b[90m 241 | \u001b[39m      expect(wrapper\u001b[33m.\u001b[39memitted()[\u001b[32m'hide-sidebar'\u001b[39m])\u001b[33m.\u001b[39mtoHaveLength(\u001b[35m1\u001b[39m)\u001b[33m;\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m    \u001b[0m \u001b[90m     | \u001b[39m                                                \u001b[31m\u001b[1m^\u001b[22m\u001b[2m\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m    \u001b[0m \u001b[90m 242 | \u001b[39m    })\u001b[33m;\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m    \u001b[0m \u001b[90m 243 | \u001b[39m    test(\u001b[32m'setMobileView does not emit hide-sidebar when transitioning to mobile view from not mobile view'\u001b[39m\u001b[33m,\u001b[39m  async () \u001b[33m=>\u001b[39m {\u001b[0m\u001b[22m\n\u001b[2m    \u001b[0m \u001b[90m 244 | \u001b[39m      \u001b[90m// Arrange\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m\u001b[22m\n\u001b[2m      \u001b[2mat \u001b[22m\u001b[2m\u001b[0m\u001b[36msrc/layouts/navbar.unit.ts\u001b[39m\u001b[0m\u001b[2m:241:49\u001b[22m\u001b[2m\u001b[22m\n\u001b[2m      \u001b[2mat fulfilled (\u001b[22m\u001b[2m\u001b[0m\u001b[36msrc/layouts/navbar.unit.ts\u001b[39m\u001b[0m\u001b[2m:5:58)\u001b[22m\u001b[2m\u001b[22m\n\u001b[2m      \u001b[2mat tryCallOne (\u001b[22m\u001b[2mnode_modules/promise/lib/core.js\u001b[2m:37:12)\u001b[22m\u001b[2m\u001b[22m\n\u001b[2m      \u001b[2mat \u001b[22m\u001b[2mnode_modules/promise/lib/core.js\u001b[2m:123:15\u001b[22m\u001b[2m\u001b[22m\n\u001b[2m      \u001b[2mat flush (\u001b[22m\u001b[2mnode_modules/asap/raw.js\u001b[2m:50:29)\u001b[22m\u001b[2m\u001b[22m\n\n\u001b[1m\u001b[31m  \u001b[1m● \u001b[22m\u001b[1mnavbar tests › view model function tests › setMobileView does not emit hide-sidebar when transitioning to mobile view from not mobile view\u001b[39m\u001b[22m\n\n    \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoHaveLength\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m)\u001b[22m\n\n    \u001b[1mMatcher error\u001b[22m: \u001b[31mreceived\u001b[39m value must have a length property whose value must be a number\n\n    Received has value: \u001b[31mundefined\u001b[39m\n\u001b[2m\u001b[22m\n\u001b[2m    \u001b[0m \u001b[90m 250 | \u001b[39m      await wrapper\u001b[33m.\u001b[39mvm\u001b[33m.\u001b[39m$nextTick()\u001b[33m;\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m    \u001b[0m \u001b[90m 251 | \u001b[39m      \u001b[90m// Assert\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m    \u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[2m\u001b[39m\u001b[90m 252 | \u001b[39m      expect(wrapper\u001b[33m.\u001b[39memitted()[\u001b[32m'hide-sidebar'\u001b[39m])\u001b[33m.\u001b[39mtoHaveLength(\u001b[35m0\u001b[39m)\u001b[33m;\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m    \u001b[0m \u001b[90m     | \u001b[39m                                                \u001b[31m\u001b[1m^\u001b[22m\u001b[2m\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m    \u001b[0m \u001b[90m 253 | \u001b[39m    })\u001b[33m;\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m    \u001b[0m \u001b[90m 254 | \u001b[39m  })\u001b[33m;\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m    \u001b[0m \u001b[90m 255 | \u001b[39m})\u001b[33m;\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m\u001b[22m\n\u001b[2m      \u001b[2mat \u001b[22m\u001b[2m\u001b[0m\u001b[36msrc/layouts/navbar.unit.ts\u001b[39m\u001b[0m\u001b[2m:252:49\u001b[22m\u001b[2m\u001b[22m\n\u001b[2m      \u001b[2mat fulfilled (\u001b[22m\u001b[2m\u001b[0m\u001b[36msrc/layouts/navbar.unit.ts\u001b[39m\u001b[0m\u001b[2m:5:58)\u001b[22m\u001b[2m\u001b[22m\n\u001b[2m      \u001b[2mat tryCallOne (\u001b[22m\u001b[2mnode_modules/promise/lib/core.js\u001b[2m:37:12)\u001b[22m\u001b[2m\u001b[22m\n\u001b[2m      \u001b[2mat \u001b[22m\u001b[2mnode_modules/promise/lib/core.js\u001b[2m:123:15\u001b[22m\u001b[2m\u001b[22m\n\u001b[2m      \u001b[2mat flush (\u001b[22m\u001b[2mnode_modules/asap/raw.js\u001b[2m:50:29)\u001b[22m\u001b[2m\u001b[22m\n",
  "numFailingTests": 2,
  "numPassingTests": 9,
  "numPendingTests": 0,
  "testResults": [
    {
      "title": "is a Vue instance",
      "numPassingAsserts": 0,
      "status": "passed",
      "failureMessages": [],
      "ancestorTitles": [
        "navbar tests",
        "creates top level menus based on user information"
      ],
      "duration": 5
    },
    {
      "title": "Creates proper menues for regular user in a club with no courts",
      "numPassingAsserts": 0,
      "status": "passed",
      "failureMessages": [],
      "ancestorTitles": [
        "navbar tests",
        "creates top level menus based on user information"
      ],
      "duration": 47
    },
    {
      "title": "Creates proper menues for regular user in a club with one court",
      "numPassingAsserts": 0,
      "status": "passed",
      "failureMessages": [],
      "ancestorTitles": [
        "navbar tests",
        "creates top level menus based on user information"
      ],
      "duration": 27
    },
    {
      "title": "Creates proper menues for regular user in a club with multiple courts",
      "numPassingAsserts": 0,
      "status": "passed",
      "failureMessages": [],
      "ancestorTitles": [
        "navbar tests",
        "creates top level menus based on user information"
      ],
      "duration": 29
    },
    {
      "title": "Creates proper menues for user with no club membership",
      "numPassingAsserts": 0,
      "status": "passed",
      "failureMessages": [],
      "ancestorTitles": [
        "navbar tests",
        "creates top level menus based on user information"
      ],
      "duration": 36
    },
    {
      "title": "Creates proper menues for regular user with announcement priviledges in a club with no courts",
      "numPassingAsserts": 0,
      "status": "passed",
      "failureMessages": [],
      "ancestorTitles": [
        "navbar tests",
        "creates top level menus based on user information"
      ],
      "duration": 26
    },
    {
      "title": "Creates proper menues for clubAdmin in a club with no courts",
      "numPassingAsserts": 0,
      "status": "passed",
      "failureMessages": [],
      "ancestorTitles": [
        "navbar tests",
        "creates top level menus based on user information"
      ],
      "duration": 20
    },
    {
      "title": "Creates proper menues for siteAdmin in a club with no courts",
      "numPassingAsserts": 0,
      "status": "passed",
      "failureMessages": [],
      "ancestorTitles": [
        "navbar tests",
        "creates top level menus based on user information"
      ],
      "duration": 24
    },
    {
      "title": "setMobileView sets the mobileView getter",
      "numPassingAsserts": 0,
      "status": "passed",
      "failureMessages": [],
      "ancestorTitles": [
        "navbar tests",
        "view model function tests"
      ],
      "duration": 30
    },
    {
      "title": "setMobileView emits hide-sidebar when transitioning to not mobile view from mobile view",
      "numPassingAsserts": 0,
      "status": "failed",
      "failureMessages": [
        "Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoHaveLength\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m)\u001b[22m\n\n\u001b[1mMatcher error\u001b[22m: \u001b[31mreceived\u001b[39m value must have a length property whose value must be a number\n\nReceived has value: \u001b[31mundefined\u001b[39m\n    at C:\\Users\\gregv\\source\\repos\\SquashSpider\\SquashSpider\\SkyCourt.UI\\SPA\\src\\layouts\\navbar.unit.ts:241:49\n    at Generator.next (<anonymous>)\n    at fulfilled (C:\\Users\\gregv\\source\\repos\\SquashSpider\\SquashSpider\\SkyCourt.UI\\SPA\\src\\layouts\\navbar.unit.ts:5:58)\n    at tryCallOne (C:\\Users\\gregv\\source\\repos\\SquashSpider\\SquashSpider\\SkyCourt.UI\\SPA\\node_modules\\promise\\lib\\core.js:37:12)\n    at C:\\Users\\gregv\\source\\repos\\SquashSpider\\SquashSpider\\SkyCourt.UI\\SPA\\node_modules\\promise\\lib\\core.js:123:15\n    at flush (C:\\Users\\gregv\\source\\repos\\SquashSpider\\SquashSpider\\SkyCourt.UI\\SPA\\node_modules\\asap\\raw.js:50:29)\n    at process._tickCallback (internal/process/next_tick.js:61:11)"
      ],
      "ancestorTitles": [
        "navbar tests",
        "view model function tests"
      ],
      "duration": 33
    },
    {
      "title": "setMobileView does not emit hide-sidebar when transitioning to mobile view from not mobile view",
      "numPassingAsserts": 0,
      "status": "failed",
      "failureMessages": [
        "Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoHaveLength\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m)\u001b[22m\n\n\u001b[1mMatcher error\u001b[22m: \u001b[31mreceived\u001b[39m value must have a length property whose value must be a number\n\nReceived has value: \u001b[31mundefined\u001b[39m\n    at C:\\Users\\gregv\\source\\repos\\SquashSpider\\SquashSpider\\SkyCourt.UI\\SPA\\src\\layouts\\navbar.unit.ts:252:49\n    at Generator.next (<anonymous>)\n    at fulfilled (C:\\Users\\gregv\\source\\repos\\SquashSpider\\SquashSpider\\SkyCourt.UI\\SPA\\src\\layouts\\navbar.unit.ts:5:58)\n    at tryCallOne (C:\\Users\\gregv\\source\\repos\\SquashSpider\\SquashSpider\\SkyCourt.UI\\SPA\\node_modules\\promise\\lib\\core.js:37:12)\n    at C:\\Users\\gregv\\source\\repos\\SquashSpider\\SquashSpider\\SkyCourt.UI\\SPA\\node_modules\\promise\\lib\\core.js:123:15\n    at flush (C:\\Users\\gregv\\source\\repos\\SquashSpider\\SquashSpider\\SkyCourt.UI\\SPA\\node_modules\\asap\\raw.js:50:29)\n    at process._tickCallback (internal/process/next_tick.js:61:11)"
      ],
      "ancestorTitles": [
        "navbar tests",
        "view model function tests"
      ],
      "duration": 3130
    }
  ],
  "aggregatedResult": null
}

It would appear that the error is on the server side that is accepting this because this was successfully sent to the server. The server spit out another message on the console saying: "i File result reported "

is this enough to go on?

gregveres avatar Feb 01 '20 01:02 gregveres

Pinging @Raathigesh in case he hasn't seen any of this yet. When this issue happens, Majestic is pretty much useless unfortunately. And at least in my case, it is happening 95% of the time, probably 100% of the time with this single unit test I am working on.

gregveres avatar Feb 01 '20 01:02 gregveres

@Raathigesh I wonder if this has anything to do with it: I get this in the chrome javascript console.

ui.bundle.js:21 Uncaught (in promise) Error: GraphQL error: This experimental syntax requires enabling the parser plugin: 'optionalChaining' (96:9)
    at new t (ui.bundle.js:21)
    at e.<anonymous> (ui.bundle.js:21)
    at ui.bundle.js:16
    at Object.next (ui.bundle.js:16)
    at ui.bundle.js:16
    at new Promise (<anonymous>)
    at l (ui.bundle.js:16)
    at ui.bundle.js:21
    at ui.bundle.js:21
    at Array.forEach (<anonymous>)

I have downloaded the github repo and tried debugging the server. It appears to be functioning correctly. It gets the proper values and seems to parse them fine from jest. So I am moving on to the UI. I want to see if the client is getting the right data from the server. That's when I noticed this error.

I don't know react or graphQL so it is going to be tough to diagnose this on the client for me.

gregveres avatar Feb 01 '20 21:02 gregveres

@Raathigesh I tried to fix the problem by installing the babel plugin: "@babel/plugin-proposal-optional-chaining" and rebuilding my local copy and copying the dist over top of my installed global version of majestic. I can't figure out how to run my development version of majestic on an external project so I am finding it hard to debug the client.

Anyway, I am now watching the debug statements in the client and I see that the client was pushed a changeToResults message via graphQL and it contained all the rigth information. So the problem appears to be somewhere in the client code when it handles the result update. A pointer would be great....

gregveres avatar Feb 01 '20 22:02 gregveres

@Raathigesh I am debugging the client and in ui/test-file/index.tsx there is a variable called fileItemResult. That is always an empty object and I believe that is causing the problem because in the render function the section where it renders the test results is rendering the fileItemResult

        {fileItemResult && (
          <TestItemsContainer>
            {roots.map(item => {
              const tree = transform(
                item as any,
                fileItemResult.items as any,
                0
              ) as any;
              return <Test key={item.id} item={tree} result={result} />;
            })}
          </TestItemsContainer>
        )}

since fileItemREsult is always an empty object, then there is nothing to render. I can't figure out how this variable is supposed to get set since I don't understand graphQL yet. It just looks like some strange code.

Ok, I think I am starting to understand. fileItemResult isn't a result, it is the structure of the test file. It is supposed to have test items in it that can be describes, it and todos.

Hey, wait a minute. My test files use 'test' instead of 'it'. When I was using jasmine I used 'it' but the examples I copied when I started using jest were using 'test' instead. Let me change that. Maybe that is the root of the problem.

If that is not the problem, then I think the problem is in parsing the structure of the file you get back from jest rather than the results. The results portion looks fine.

gregveres avatar Feb 01 '20 22:02 gregveres

@Raathigesh Here is what I have found out so far: The response to the query:

{"operationName":"FileItems","variables":{"path":"C:\\Users\\gregv\\source\\repos\\SquashSpider\\SquashSpider\\SkyCourt.UI\\SPA\\src\\layouts\\navbar.unit.ts"},"query":"query FileItems($path: String!) {\n  file(path: $path) {\n    items {\n      id\n      name\n      type\n      parent\n      only\n      __typename\n    }\n    __typename\n  }\n}\n"}

is an error and this is what screws up the listing of the tests, I believe. Here is the response to this query:

{"data":null,"errors":[{"message":"This experimental syntax requires enabling the parser plugin: 'optionalChaining' (96:9)","locations":[{"line":2,"column":3}],"path":["file"]}]}

Could you look into fixing this? With it broken like this Majestic is pretty much useless. I will switch to seeing if I can figure out if it is something in my test file that is triggering it.

gregveres avatar Feb 02 '20 01:02 gregveres

BTW, in case it wasn't clear, the error is coming from the server when we query for the fileItems. So I was mistaken when I said it looked like the problem was on the client.

gregveres avatar Feb 02 '20 01:02 gregveres

@Raathigesh BREAK THROUGH!!! The issue is that in my unit test file (which is typescript), I had this function:

  afterAll(() => {
    wrapper?.destroy();
  });

The issue is the ?. operator. I don't know what version of babel is processing that file, but whatever installation of babel is doing it, doesn't know how to handle the ?. operator and throws an error while parsing it.

The strange thing is that this works just fine when I run jest without Majestic.

@IPWright83, @GoMino, @IGionny, You guys may have moved on by now, but I think this might be a work around for the issue you were having if it is the same as the one I was having. To check, open chrome debugger and look to see if you are seeing a network error like this:

ui.bundle.js:21 Uncaught (in promise) Error: GraphQL error: This experimental syntax requires enabling the parser plugin: 'optionalChaining' (96:9)
    at new t (ui.bundle.js:21)

If you are, then you are using ?. in your unit test file. If you remove it, then Majestic will work fine. I suspect there are other newer features of JS/TS that would result in a similar message. If you use another new feature, the optionalChaining message will be replaced with whatever feature you are using.

For now, I will avoid optionalchaining in my unit test files. And in the background, I will try to figure out where the configuration is for babel that is trying to transpile the unit test files. There is a configuration that can be set to include a babel plugin to transpile that code properly.

gregveres avatar Feb 02 '20 02:02 gregveres

@gregveres Thank you for digging through the details to find the root cause. Appreciate it.

I think the parser we use to extract the test names from a test file is not handling the optional chaining properly.

Enabling the support for optional chaining, by looking at the docs, could be easy as adding the 'optionalChaining' to the plugin array in the above-mentioned file.

Do you think you would be able to make PR with the change?

Raathigesh avatar Feb 02 '20 05:02 Raathigesh

@Raathigesh pull request created. It turned out to be quite simple once you pointed me to that file. I would have never found the right file otherwise. Thank you.

I did a 'yarn run prod' on my branch and then copied the server directory over top of my globally installed copy of majestic and then launched majestic on my project. All the unit tests showed up properly even when I had used optional chaining in the tests.

gregveres avatar Feb 02 '20 14:02 gregveres

@gregveres wow, I've only just come across these updates. Awesome work and digging. I probably need to go through the same.

Unfortunately for me we had no optional chaining, so this is unlikely to fix the problem I was having with the tests.

IPWright83 avatar Feb 04 '20 12:02 IPWright83

@IPWright83 now that I am done with the investigation, I can look back and short circuit a lot of it. :) If you open the chrome debugger and see an error message that says something like:

ui.bundle.js:21 Uncaught (in promise) Error: GraphQL error: This experimental syntax requires enabling the parser plugin: 'optionalChaining' (96:9)
    at new t (ui.bundle.js:21)

Yours will probably say something different than optionalChaining in the plugin field. There are many other plugins that could be added based on the features you are using in your test code.

gregveres avatar Feb 04 '20 12:02 gregveres

@gregveres thanks, I'll take a look at some point :)

IPWright83 avatar Feb 04 '20 13:02 IPWright83

I also have the same problem, says failing tests, but these are not shown in the UI, switching to the console shows the tests Jest failed. Any update on this?

pdashford avatar May 11 '20 13:05 pdashford

@pdashford this has been fixed by PR #178. I see that there have been a number of pull requests merged lately so maybe a new npm version is about to come out.

gregveres avatar May 11 '20 14:05 gregveres

Thanks @gregveres

pdashford avatar May 11 '20 14:05 pdashford

@gregveres the optional chaining change is released as a part of https://github.com/Raathigesh/majestic/releases/tag/v1.7.0

@pdashford If you could provide a sample repo, that would be really helpful to investigate.

Raathigesh avatar May 13 '20 09:05 Raathigesh