tomitrescak / luis

27 stars 3 forks source link

Add support for Mocha and Jasmine #13

Open tomitrescak opened 5 years ago

tomitrescak commented 5 years ago

@nishatshama please add support for Mocha and Jasmine. All we need is a reporter that stores following format:

module.exports.report = {
  "numFailedTests": 3,
  "numPassedTests": 5,
  "numTotalTests": 8,
  "testResults": [
    {
      "testFilePath": "/tests/foo.test",
      "testResults": [
        {
          "ancestorTitles": [
            "Component",
            "Foo"
          ],
          "duration": 2,
          "failureMessages": [],
          "fullName": "Component Foo renders correctly",
          "location": null,
          "numPassingAsserts": 0,
          "status": "passed",
          "title": "renders correctly"
        },
        {
          "ancestorTitles": [
            "Component",
            "Foo"
          ],
          "duration": 0,
          "failureMessages": [
            "Error Message" 
          ],
          "fullName": "Component Foo shows difference",
          "location": null,
          "numPassingAsserts": 0,
          "status": "failed",
          "title": "shows difference"
        },
      ],
      "numFailingTests": 1,
      "numPassingTests": 1
    },
  ]
}

module.exports.snapshots = {
    '/tests/apollo.test':  require('./tests/__snapshots__/apollo.test.tsx.snap'),
    ....
}

What you see is that tests are reported per test suite (file) and each file reports all tests ran in that file.

I have already prepared the files for you with the base structure. The files are in /src/jasmine/reporter.ts and /src/mocha/reporter.ts.

For now we do not have to do the snapshots, but we will definitely look into supporting them in the future as I wrote a custom package for mocha snapshots some time ago.