@suffolklitlab/alkiln 5.8.1-feat2columns3 → 5.8.1-feat2columns5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -88,5 +88,5 @@ jobs:
88
88
  #### Developer note: Useful for temporarily shortening ALKiln tests
89
89
  #### to debug the docker install step
90
90
  # ALKILN_TAG_EXPRESSION: @a_tag_expression
91
- ALKILN_VERSION: 5.8.1-feat2columns3
91
+ ALKILN_VERSION: 2columns
92
92
 
@@ -55,4 +55,4 @@ jobs:
55
55
  #### to debug the docker install step
56
56
  # ALKILN_TAG_EXPRESSION: @a_tag_expression
57
57
  #### Developer note: you probalby don't need this
58
- ALKILN_VERSION: 5.8.1-feat2columns3
58
+ ALKILN_VERSION: 2columns
@@ -0,0 +1,15 @@
1
+ # What results are we expecting in our own tests?
2
+
3
+ Our internal test results look a little strange. For example, they sometimes initially look like they're failing, but eventually pass. That's because we're testing that our tests respond appropriately to authors' failures as well as successees.
4
+
5
+ These are the results that we expect:
6
+
7
+ ## Cucumber feature tests {#cucumber}
8
+
9
+ - Many red `F`s in our cucumber "progress bar"
10
+ - Final results to show all Scenarios passing
11
+ - Cucumber seems to be unable to print the name of the first scenario
12
+
13
+ ## Unit tests {#unit}
14
+
15
+ All these must pass
package/lib/steps.js CHANGED
@@ -106,6 +106,12 @@ BeforeAll(async () => {
106
106
  });
107
107
 
108
108
  Before(async (scenario) => {
109
+
110
+ // Useful for those with a lot of tests
111
+ // Is unable to print the first Scenario name for some reason
112
+ console.log('');
113
+ process.stdout.write(`Scenario: ${ scenario.pickle.name }: `);
114
+
109
115
  // Create browser, which can't be created in BeforeAll() where .driver doesn't exist for some reason
110
116
  if (!scope.browser) {
111
117
  if (session_vars.get_origin() === 'playground') {
@@ -1244,8 +1250,8 @@ Given(/the Scenario report should not include/i, async ( report_text ) => {
1244
1250
 
1245
1251
  });
1246
1252
 
1247
- Given(/the final Scenario status should be "(passed|failed)"/i, async ( expected_status ) => {
1248
- /* WARNING: If a Step will fail, this Step must come first.
1253
+ Given(/the final Scenario status should be "([^"]+)"/i, async ( expected_status ) => {
1254
+ /** WARNING: If a Step will fail, this Step must come first.
1249
1255
  *
1250
1256
  * Prepare to test that the Scenario completes with the correct status. */
1251
1257
  scope.expected_status = expected_status.toUpperCase();
@@ -1327,39 +1333,46 @@ After(async function(scenario) {
1327
1333
 
1328
1334
  } // ends if not passed
1329
1335
 
1330
- // Internal tests of this framework
1331
- if ( scope.expected_status ) {
1332
- let expected = scope.expected_status;
1333
- scope.expected_status = null; // reset for next Scenario
1334
- expect( changeable_test_status ).to.equal( expected );
1335
- // If the status was as expected, pass this criteria
1336
- changeable_test_status = `PASSED`;
1337
- }
1338
-
1336
+ // Add report text to Scenario folder after everything has been added to the report
1337
+ let current_report_obj = scope.report.get( scope.scenario_id );
1338
+ let scenario_report_obj = [ scope.scenario_id, current_report_obj ]; // Mimic how loop works with `Map`
1339
+ let report = reports.getPrintableScenario( scenario_report_obj );
1340
+ // Save the report as in the Scenario folder
1341
+ fs.writeFileSync( scope.paths.scenario_report, report );
1342
+
1343
+ // ---------------- Check internal test results of this framework ----------------
1344
+
1339
1345
  if ( scope.expected_in_report && scope.expected_in_report.length > 0) {
1340
- let expected = scope.expected_in_report;
1346
+ let report_includes_all_expected_strings = await scope.reportIncludesAllExpected(
1347
+ scope,
1348
+ { expected: scope.expected_in_report }
1349
+ );
1350
+ if ( !report_includes_all_expected_strings ) { changeable_test_status = `FAILED`; }
1341
1351
  // Reset report values no matter what so they don't mess up future scenarios
1342
1352
  scope.expected_in_report = null;
1343
- let all_were_included = await scope.reportIncludesAllExpected( scope, { expected });
1344
-
1345
- if ( all_were_included ) { changeable_test_status = `PASSED`; }
1346
- else { changeable_test_status = `FAILED`; }
1347
1353
  }
1348
1354
 
1349
1355
  if (scope.expected_not_in_report && scope.expected_not_in_report.length > 0) {
1350
- let not_expected = scope.expected_not_in_report;
1356
+ let all_prohibited_strings_were_absent = await scope.reportDoesNotInclude(
1357
+ scope,
1358
+ { not_expected: scope.expected_not_in_report }
1359
+ );
1360
+ if ( !all_prohibited_strings_were_absent ) { changeable_test_status = `FAILED`;}
1351
1361
  // Reset report values no matter what so they don't mess up future scenarios
1352
1362
  scope.expected_not_in_report = null;
1353
- let all_were_not_there = await scope.reportDoesNotInclude( scope, { not_expected });
1354
-
1355
- if ( all_were_not_there ) {
1356
- changeable_test_status = `PASSED`;
1357
- } else {
1358
- changeable_test_status = `FAILED`;
1359
- }
1363
+ }
1360
1364
 
1365
+ // The default is 'passed', which won't need to get in here
1366
+ if ( scope.expected_status ) {
1367
+ // When internal tests should fail (to test our failure conditions), passing _is_ failing
1368
+ expect( changeable_test_status ).to.equal( scope.expected_status );
1369
+ // If the status was as expected, pass this Scenario
1370
+ changeable_test_status = `PASSED`;
1371
+ scope.expected_status = null; // reset for next Scenario
1361
1372
  }
1362
1373
 
1374
+ // ---------------- Ends check internal test results of this framework ----------------
1375
+
1363
1376
  // If there is a page open, then sign out and close it
1364
1377
  if ( scope.page ) {
1365
1378
  // Catch a possible reload error.
@@ -1387,23 +1400,19 @@ After(async function(scenario) {
1387
1400
 
1388
1401
  } // ends if scope.page
1389
1402
 
1390
- // Add report text to Scenario folder after everything has been added to the report
1391
- let current_report_obj = scope.report.get( scope.scenario_id );
1392
- let scenario_report_obj = [ scope.scenario_id, current_report_obj ]; // Mimic how loop works with `Map`
1393
- let report = reports.getPrintableScenario( scenario_report_obj );
1394
- // Save the report as in the Scenario folder
1395
- fs.writeFileSync( scope.paths.scenario_report, report );
1396
-
1397
1403
  if ( changeable_test_status === `FAILED` ) {
1398
1404
  // If the result object status wasn't failure and we still want
1399
1405
  // the tests to fail, as with a11y tests, we can't mess with the
1400
1406
  // cucumber result.status object because it will cause unwanted
1401
1407
  // errors. We have to throw an error here instead.
1402
1408
  if ( scenario.result.status !== `FAILED` ) {
1403
- throw new Error(`The test failed. See the report for more information.`);
1409
+ throw new Error(`The test failed. See the report above for more information.`);
1404
1410
  }
1405
1411
  } else {
1406
- // Other types of errors should be ok
1412
+ // Some internal test failures should be ok
1413
+ // TODO: Look into setDefinitionFunctionWrapper to catch errors
1414
+ // of failing tests that should indeed be failing:
1415
+ // https://github.com/cucumber/cucumber-js/blob/main/docs/support_files/api_reference.md#setdefinitionfunctionwrapperwrapper
1407
1416
  scenario.result.status = changeable_test_status;
1408
1417
  }
1409
1418
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suffolklitlab/alkiln",
3
- "version": "5.8.1-feat2columns3",
3
+ "version": "5.8.1-feat2columns5",
4
4
  "description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {