From 46c1089aa7a5ab0f18bfb245549fb8d97f46cc37 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 6 Nov 2024 11:40:38 -0700 Subject: [PATCH 1/6] refactor: use import instead of require --- test/mocha_debug.js | 2 +- test/specs/commandsLogging.spec.js | 3 +-- test/specs/compactLogs.spec.js | 3 +-- test/specs/componentTesting.spec.js | 3 +-- test/specs/extendedController.spec.js | 3 +-- .../filteringAndConditionalLogging.spec.js | 4 +--- test/specs/misc.spec.js | 4 +--- test/specs/otherPluginIntegration.spec.js | 7 +++---- test/specs/outputCompactLogs.spec.js | 7 +++---- test/specs/outputToFiles.spec.js | 18 ++++++++---------- test/specs/validation.spec.js | 3 +-- test/utils.js | 12 ++++++------ 12 files changed, 28 insertions(+), 41 deletions(-) diff --git a/test/mocha_debug.js b/test/mocha_debug.js index 25a5fd5..ee9702d 100644 --- a/test/mocha_debug.js +++ b/test/mocha_debug.js @@ -1,4 +1,4 @@ -const {expect} = require('chai'); +import { expect } from 'chai' describe('Always red test', function () { before(function () { diff --git a/test/specs/commandsLogging.spec.js b/test/specs/commandsLogging.spec.js index 43da03b..fd41add 100755 --- a/test/specs/commandsLogging.spec.js +++ b/test/specs/commandsLogging.spec.js @@ -5,8 +5,7 @@ import { runTest, commandBase, logLastRun, } from "../utils"; - -const {expect} = require('chai'); +import { expect } from 'chai' describe('Commands logging.', () => { diff --git a/test/specs/compactLogs.spec.js b/test/specs/compactLogs.spec.js index 4997040..ef64319 100755 --- a/test/specs/compactLogs.spec.js +++ b/test/specs/compactLogs.spec.js @@ -3,8 +3,7 @@ import { runTest, commandBase, logLastRun, } from "../utils"; - -const {expect} = require('chai'); +import { expect } from 'chai' describe('Compact logs.', () => { diff --git a/test/specs/componentTesting.spec.js b/test/specs/componentTesting.spec.js index f9d64ae..ceb6822 100755 --- a/test/specs/componentTesting.spec.js +++ b/test/specs/componentTesting.spec.js @@ -3,8 +3,7 @@ import { runTest, commandBase, logLastRun, } from "../utils"; - -const {expect} = require('chai'); +import { expect } from 'chai' describe('Component testing support.', () => { diff --git a/test/specs/extendedController.spec.js b/test/specs/extendedController.spec.js index 8f571e0..4dd95ff 100755 --- a/test/specs/extendedController.spec.js +++ b/test/specs/extendedController.spec.js @@ -6,8 +6,7 @@ import { expectOutputFilesToBeCorrect, outputCleanUpAndInitialization, logLastRun, } from "../utils"; - -const {expect} = require('chai'); +import { expect } from 'chai' require('chai').config.truncateThreshold = 0; describe('Extended controller.', () => { diff --git a/test/specs/filteringAndConditionalLogging.spec.js b/test/specs/filteringAndConditionalLogging.spec.js index 5bceaa3..bbed580 100755 --- a/test/specs/filteringAndConditionalLogging.spec.js +++ b/test/specs/filteringAndConditionalLogging.spec.js @@ -3,9 +3,7 @@ import { runTest, commandBase, logLastRun, } from "../utils"; - -const {expect} = require('chai'); -const chalk = require('chalk'); +import { expect } from 'chai' describe('Filtering and conditional logging.', () => { diff --git a/test/specs/misc.spec.js b/test/specs/misc.spec.js index 7c2bc53..557ebdc 100755 --- a/test/specs/misc.spec.js +++ b/test/specs/misc.spec.js @@ -7,10 +7,8 @@ import { runTestContinuous, outputCleanUpAndInitialization, expectOutputFilesToBeCorrect, - PADDING, } from "../utils"; - -const {expect} = require('chai'); +import { expect } from 'chai' describe('Misc.', () => { diff --git a/test/specs/otherPluginIntegration.spec.js b/test/specs/otherPluginIntegration.spec.js index 0733b08..9cd0c26 100755 --- a/test/specs/otherPluginIntegration.spec.js +++ b/test/specs/otherPluginIntegration.spec.js @@ -4,10 +4,9 @@ import { commandBase, expectOutFilesMatch, logLastRun, } from "../utils"; - -const {expect} = require('chai'); -const fs = require('fs'); -const glob = require('glob'); +import { expect } from 'chai' +import * as fs from 'fs' +import * as glob from 'glob' describe('Other plugin integrations.', () => { diff --git a/test/specs/outputCompactLogs.spec.js b/test/specs/outputCompactLogs.spec.js index 97d238f..94346e9 100644 --- a/test/specs/outputCompactLogs.spec.js +++ b/test/specs/outputCompactLogs.spec.js @@ -1,8 +1,7 @@ import { runTest, commandBase, logLastRun, clean } from "../utils"; - -const {expect} = require('chai'); -const fs = require('fs'); -const path = require('path'); +import { expect } from 'chai' +import * as fs from 'fs' +import * as path from 'path' function getOutputFileContents() { const outputFile = path.join(__dirname, '../output/out.txt'); diff --git a/test/specs/outputToFiles.spec.js b/test/specs/outputToFiles.spec.js index a45b7a7..6815522 100755 --- a/test/specs/outputToFiles.spec.js +++ b/test/specs/outputToFiles.spec.js @@ -6,12 +6,10 @@ import { expectOutFilesMatch, outputCleanUpAndInitialization, logLastRun, } from "../utils"; - -const {expect} = require('chai'); -const fs = require('fs'); -const fsExtra = require('fs-extra'); -const path = require('path'); -const glob = require('glob'); +import { expect } from 'chai' +import * as fs from 'fs' +import * as glob from 'glob' +import fsExtra from 'fs-extra' describe('Output to files.', () => { @@ -86,21 +84,21 @@ describe('Output to files.', () => { 'callsSuiteInAnotherFile.spec.js' ]; await runTest(commandBase(['generateNestedOutput=1'], specFiles), (error, stdout) => { - const specs = glob.sync('./output_nested_spec/**/*', {nodir: true}); + const specs = glob.sync('./output_nested_spec/**/*', { nodir: true }); specs.forEach(specFile => { const actualFile = specFile.replace('output_nested_spec', 'output_nested'); expect(fs.existsSync(actualFile), `Expected output file ${actualFile} to exist.`).to.be.true; expectOutFilesMatch(actualFile, specFile); }); - const shouldNotExist = glob.sync('./output_nested/**/suiteInOtherFile*', {nodir: true}); + const shouldNotExist = glob.sync('./output_nested/**/suiteInOtherFile*', { nodir: true }); expect(shouldNotExist, `Expect no output file for suiteInOtherFile to exist.`).to.have.length(0); }); }).timeout(90000); it('Should generate output only for failing tests if set to onFail.', async () => { - const outRoot = {value: path.join(__dirname, '../output')}; - const testOutputs = {value: ["out.txt"]}; + const outRoot = { value: path.join(__dirname, '../output') }; + const testOutputs = { value: ["out.txt"] }; const specFiles = ['printLogsOnFail.spec.js']; await runTest(commandBase(['generateSimpleOutput=1'], specFiles), (error, stdout, stderr) => { diff --git a/test/specs/validation.spec.js b/test/specs/validation.spec.js index e3b3992..493db0c 100755 --- a/test/specs/validation.spec.js +++ b/test/specs/validation.spec.js @@ -2,8 +2,7 @@ import { runTest, commandBase, logLastRun, } from "../utils"; - -const {expect} = require('chai'); +import { expect } from 'chai' describe('Validation.', () => { diff --git a/test/utils.js b/test/utils.js index 3e490b9..4a36c4a 100644 --- a/test/utils.js +++ b/test/utils.js @@ -1,9 +1,9 @@ -const {exec, spawn} = require('child_process'); -const {expect} = require('chai'); -const fs = require('fs'); -const path = require('path'); -const os = require('os'); -const chalk = require('chalk'); +import { exec, spawn } from 'child_process' +import { expect } from 'chai' +import * as fs from 'fs' +import * as path from 'path' +import * as os from 'os' +import chalk from 'chalk' let commandPrefix = 'node ./node_modules/.bin/cypress'; From dc8fe025b3f39795618e4b902b24df22d40902c4 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 6 Nov 2024 11:48:04 -0700 Subject: [PATCH 2/6] style --- test/specs/outputToFiles.spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/specs/outputToFiles.spec.js b/test/specs/outputToFiles.spec.js index 6815522..d8cef82 100755 --- a/test/specs/outputToFiles.spec.js +++ b/test/specs/outputToFiles.spec.js @@ -84,21 +84,21 @@ describe('Output to files.', () => { 'callsSuiteInAnotherFile.spec.js' ]; await runTest(commandBase(['generateNestedOutput=1'], specFiles), (error, stdout) => { - const specs = glob.sync('./output_nested_spec/**/*', { nodir: true }); + const specs = glob.sync('./output_nested_spec/**/*', {nodir: true}); specs.forEach(specFile => { const actualFile = specFile.replace('output_nested_spec', 'output_nested'); expect(fs.existsSync(actualFile), `Expected output file ${actualFile} to exist.`).to.be.true; expectOutFilesMatch(actualFile, specFile); }); - const shouldNotExist = glob.sync('./output_nested/**/suiteInOtherFile*', { nodir: true }); + const shouldNotExist = glob.sync('./output_nested/**/suiteInOtherFile*', {nodir: true}); expect(shouldNotExist, `Expect no output file for suiteInOtherFile to exist.`).to.have.length(0); }); }).timeout(90000); it('Should generate output only for failing tests if set to onFail.', async () => { - const outRoot = { value: path.join(__dirname, '../output') }; - const testOutputs = { value: ["out.txt"] }; + const outRoot = {value: path.join(__dirname, '../output')}; + const testOutputs = {value: ["out.txt"]}; const specFiles = ['printLogsOnFail.spec.js']; await runTest(commandBase(['generateSimpleOutput=1'], specFiles), (error, stdout, stderr) => { From 3c39412687302e6429ff088edf6e1e655e1d8b15 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 6 Nov 2024 11:51:16 -0700 Subject: [PATCH 3/6] fix import --- test/specs/outputToFiles.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/specs/outputToFiles.spec.js b/test/specs/outputToFiles.spec.js index d8cef82..7076139 100755 --- a/test/specs/outputToFiles.spec.js +++ b/test/specs/outputToFiles.spec.js @@ -8,6 +8,7 @@ import { } from "../utils"; import { expect } from 'chai' import * as fs from 'fs' +import * as path from 'path' import * as glob from 'glob' import fsExtra from 'fs-extra' From 4583ddf91ffa77977d7f31f809ae1dd89893efb5 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 6 Nov 2024 12:05:17 -0700 Subject: [PATCH 4/6] more imports --- test/mock_server.js | 5 +++-- test/webpack.config.js | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/mock_server.js b/test/mock_server.js index d2f08e6..0c51844 100644 --- a/test/mock_server.js +++ b/test/mock_server.js @@ -1,6 +1,7 @@ -const express = require('express'); +import express from "express" +import cors from "cors" + const app = express(); -const cors = require('cors') app.use(cors({ origin: '*' diff --git a/test/webpack.config.js b/test/webpack.config.js index e7beb9b..660e948 100644 --- a/test/webpack.config.js +++ b/test/webpack.config.js @@ -1,6 +1,6 @@ -const path = require('path'); -const webpack = require('webpack'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); +import * as path from 'path'; +import webpack from 'webpack'; +import HtmlWebpackPlugin from 'html-webpack-plugin'; module.exports = { mode: 'development', From 48799f192edcfba72fbeef43acd5880f7d1cdd55 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 6 Nov 2024 12:16:21 -0700 Subject: [PATCH 5/6] revert --- test/mock_server.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/mock_server.js b/test/mock_server.js index 0c51844..d2f08e6 100644 --- a/test/mock_server.js +++ b/test/mock_server.js @@ -1,7 +1,6 @@ -import express from "express" -import cors from "cors" - +const express = require('express'); const app = express(); +const cors = require('cors') app.use(cors({ origin: '*' From f0c84e84fd0ddce57b4b47320a17212b7f07ef53 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 6 Nov 2024 12:23:45 -0700 Subject: [PATCH 6/6] revert --- test/webpack.config.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/webpack.config.js b/test/webpack.config.js index 660e948..e7beb9b 100644 --- a/test/webpack.config.js +++ b/test/webpack.config.js @@ -1,6 +1,6 @@ -import * as path from 'path'; -import webpack from 'webpack'; -import HtmlWebpackPlugin from 'html-webpack-plugin'; +const path = require('path'); +const webpack = require('webpack'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { mode: 'development',