[FOLIO-1618] Update existing Nightmare tests to support coverage Created: 20/Nov/18  Updated: 22/Oct/20  Resolved: 22/Oct/20

Status: Closed
Project: FOLIO
Components: None
Affects versions: None
Fix versions: None

Type: Umbrella Priority: P3
Reporter: Matthew Jones Assignee: Unassigned
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original estimate: Not Specified

Issue links:
Relates
relates to FOLIO-1619 Update platform-core nightmare tests ... Closed
relates to FOLIO-1620 Update ui-audit nightmare tests to su... Closed
relates to STCLI-118 Update reference ui-module nightmare ... Closed
relates to UICHKOUT-474 Update ui-checkout nightmare tests to... Closed
relates to UICIRC-111 Update ui-circulation nightmare tests... Closed
relates to UIIN-392 Update ui-inventory nightmare tests t... Closed
relates to UIREQ-169 Update ui-requests nightmare tests to... Closed
relates to UISE-92 Update ui-search nightmare tests to s... Closed
relates to UITEN-25 Update ui-organization nightmare test... Closed
relates to FOLIO-1660 platform-core tests fail as a suite Closed
relates to UIU-777 integration tests fail when run as a ... Closed
relates to FOLIO-1602 Enable coverage reporting on UI night... Closed
relates to UITEST-39 Add coverage functionality to stripes... Closed
Sprint:
Development Team: Core: Platform

 Description   

**Note: We should selectively update a couple modules and verify results before rolling this out to all.**

Update nightmare tests in ui-modules and platforms to use the pattern outlined in ui-users. This change will allow for enabling of code coverage enabled by UITEST-39 Closed and demonstrated in UIU-570 Open .

The main change is to accept a Nightmare object instantiated outside of the test, rather than creating a new one within each test.

For example, from this:

module.exports.test = function myTests(uiTestCtx) {
  describe('Example', function () {
    const nightmare = new Nightmare(config.nightmare);
    nightmare.foo()
    //...
  }
}

To this:

module.exports.test = function myTests(uiTestCtx, nightmare) {
  describe('Example', function () {
    nightmare.foo()
    //...
  }
}

Also remove any direct calls to .end() on the Nightmare instance within tests. End will be called on the shared instance after all tests are run. This includes use of the logout() helper method which internally calls end. A new helper method, logoutWithoutEnd() has been created to accommodate the transition.

Example, from this:

const { helpers: { login, logout } } = uiTestCtx;
//...
after( function (done) {
  logout(nightmare, config, done);
});

To this:

const { helpers: { login, logoutWithoutEnd } } = uiTestCtx;
//...
after( function (done) {
  logoutWithoutEnd(nightmare, config, done);
});

Finally, although not required, this may be a good opportunity to review and replace our use of arrow functions for the Mocha test scaffolding (describe, it, before, after, etc). Due to the lexically bound this of the arrow function, access to Mohca's context is blocked and therefore not recommended.

For example, rather than this:

it('should do something', (done) => {
  // ...
}

Do this:

it('should do something', function (done) {
  // ...
}


 Comments   
Comment by Matthew Jones [ 20/Nov/18 ]

Jakub Skoczen, I have created and linked JIRA tasks for the modules and platforms which appear to have existing Nightmare tests written. I recommend we trial the upgrade on a module or two before rolling out the change to all. This would give us a chance to update the instructions in this ticket with any issues encountered. Zak Burke do you have a recommendation for a candidate module? Perhaps one that has shown to be relatively stable recently.

Also, there are more modules with Nightmare tests that I did not create tickets for. However, they only have a placeholder tests (from creating a new ui-module via the CLI). These others include platform-erm, ui-finance, ui-vendors, ui-receiving, ui-licenses, and ui-erm-usage.

Comment by Zak Burke [ 28/Nov/18 ]

checkout, circulation, or organization are all relatively small and would be good candidates.

Comment by Jakub Skoczen [ 10/Dec/18 ]

John Malconian what needs to be done to integrate those coverage reports into the Jenkins runs?

Comment by Zak Burke [ 15/Dec/18 ]

In light of UIU-777 Closed and FOLIO-1660 Closed , I think this isn't ready to pursue at present.

Comment by Khalilah Gambrell [ 22/Oct/20 ]

Moving to a new testing framework

Generated at Thu Feb 08 23:14:39 UTC 2024 using Jira 1001.0.0-SNAPSHOT#100246-sha1:7a5c50119eb0633d306e14180817ddef5e80c75d.