Skip to content

Commit

Permalink
fix(yarn): downgrade yarn (#153)
Browse files Browse the repository at this point in the history
yarn 4 requires node 18 which causes issues with testcafe (not closing browsers properly) this makes
testing the package needlessly complicated
  • Loading branch information
Arthy000 committed Jan 7, 2024
1 parent 60b4bdc commit 078803d
Show file tree
Hide file tree
Showing 7 changed files with 2,505 additions and 2,035 deletions.
541 changes: 541 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

801 changes: 801 additions & 0 deletions .yarn/releases/yarn-3.2.4.cjs

Large diffs are not rendered by default.

893 changes: 0 additions & 893 deletions .yarn/releases/yarn-4.0.2.cjs

This file was deleted.

6 changes: 5 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.0.2.cjs
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"

yarnPath: .yarn/releases/yarn-3.2.4.cjs
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
"@cucumber/cucumber-expressions": "^17.0.1",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "3.3.0",
"jest": "^29.6.4",
"prettier": "^3.0.2",
"jest": "^29.7.0",
"prettier": "^3.1.1",
"standard-version": "^9.5.0",
"testcafe": "3.5.0"
},
Expand All @@ -88,5 +88,5 @@
"postbump": "node ./tools/update-version-matrix.js && git add version-matrix.md tools/version-matrix.json"
}
},
"packageManager": "yarn@4.0.2"
"packageManager": "yarn@3.2.4"
}
23 changes: 12 additions & 11 deletions src/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const TestcafeTypescriptCompiler = require('testcafe/lib/compiler/test-file/form
const CustomizableCompilers = require('testcafe/lib/configuration/customizable-compilers');
const { readFileSync, existsSync } = require('fs');
const { IdGenerator } = require('@cucumber/messages');
const chalk = require('chalk');

const chalk = import('chalk');

const AND_SEPARATOR = ' and ';

Expand Down Expand Up @@ -92,7 +93,7 @@ module.exports = class GherkinTestcafeCompiler {
...gherkinResult
.filter(({ attachment }) => Boolean(attachment))
.map(({ attachment }) => attachment.source.uri + attachment.data),
].join('\n')
].join('\n'),
);
}
return { gherkinResult, gherkinDocument, testFile, fixture };
Expand Down Expand Up @@ -128,19 +129,19 @@ module.exports = class GherkinTestcafeCompiler {
const missingFeatureSteps = featureSteps.filter((step) => !this._findStepDefinition(step));

return { featureTitle, featureSteps, missingFeatureSteps };
})
}),
);

featureStepsArray.map(({ featureTitle, featureSteps, missingFeatureSteps }) => {
const color = missingFeatureSteps.length === 0 ? 'green' : 'red';
console.log(`\n ${featureTitle}`);
console.log(
` Steps: ${chalk[color](`${featureSteps.length - missingFeatureSteps.length}/${featureSteps.length}`)}`
` Steps: ${chalk[color](`${featureSteps.length - missingFeatureSteps.length}/${featureSteps.length}`)}`,
);
if (missingFeatureSteps.length) {
console.log(
` Missing steps:`,
chalk.red(missingFeatureSteps.reduce((acc, cur) => `${acc}\n ${cur}`, ''))
chalk.red(missingFeatureSteps.reduce((acc, cur) => `${acc}\n ${cur}`, '')),
);
}
});
Expand Down Expand Up @@ -176,7 +177,7 @@ module.exports = class GherkinTestcafeCompiler {
.filter((filename) => existsSync(filename));
if (foundCredentialFiles.length > 1) {
console.warn(
`Looks like you have several credential files for ${specFile}. ${foundCredentialFiles[0]} will be used`
`Looks like you have several credential files for ${specFile}. ${foundCredentialFiles[0]} will be used`,
);
}

Expand Down Expand Up @@ -233,7 +234,7 @@ module.exports = class GherkinTestcafeCompiler {
: '',
steps: scenario.steps.map(({ type, text, astNodeIds }) => {
const backgroundStepNode = backgroundNode?.background.steps.find(
(stepNode) => stepNode.id === astNodeIds[0]
(stepNode) => stepNode.id === astNodeIds[0],
);
const stepNode = scenarioNode.scenario.steps.find((stepNode) => stepNode.id === astNodeIds[0]);
return {
Expand All @@ -251,7 +252,7 @@ module.exports = class GherkinTestcafeCompiler {
});

return testFile.collectedTests;
})
}),
);

tests = tests.reduce((agg, cur) => agg.concat(cur));
Expand Down Expand Up @@ -285,7 +286,7 @@ module.exports = class GherkinTestcafeCompiler {
const code = readFileSync(filename, 'utf-8');

return { code, filename };
})
}),
);

testFiles.forEach((filename, index) => {
Expand Down Expand Up @@ -362,7 +363,7 @@ module.exports = class GherkinTestcafeCompiler {
if (typeof stepDefinition.pattern === 'string') {
const cucumberExpression = new cucumberExpressions.CucumberExpression(
stepDefinition.pattern,
this.cucumberExpressionParamRegistry
this.cucumberExpressionParamRegistry,
);

const matchResult = cucumberExpression.match(step.text);
Expand Down Expand Up @@ -418,7 +419,7 @@ module.exports = class GherkinTestcafeCompiler {
const scenarioTagsList = scenario.tags.map((tag) => tag.name);

return tags.every((tag) =>
tag.startsWith('~') ? !scenarioTagsList.includes(tag.slice(1)) : scenarioTagsList.includes(tag)
tag.startsWith('~') ? !scenarioTagsList.includes(tag.slice(1)) : scenarioTagsList.includes(tag),
);
}

Expand Down
Loading

0 comments on commit 078803d

Please sign in to comment.