Skip to content

Commit

Permalink
fix(cypress): use cypress 10
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed Nov 18, 2022
1 parent cb642b8 commit dc81381
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.vscode/
.history
.eslintrc.js
nyc_output
.nyc_output
project
coverage
logs
Expand Down
43 changes: 21 additions & 22 deletions .project.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,48 @@
const fs = require("fs");
const path = require("path");

const projectRootPath = fs.existsSync("./project")
? fs.realpathSync("./project")
: fs.realpathSync("./../../../");
const packageJson = require(path.join(projectRootPath, "package.json"));
const jsConfig = require(path.join(
projectRootPath,
"jsconfig.json"
)).compilerOptions;
const fs = require('fs');
const path = require('path');

const projectRootPath = fs.existsSync('./project')
? fs.realpathSync('./project')
: fs.realpathSync('./../../../');
const packageJson = require(path.join(projectRootPath, 'package.json'));
const jsConfig = require(path.join(projectRootPath, 'jsconfig.json')).compilerOptions;

const pathsConfig = jsConfig.paths;

let voltoPath = path.join(projectRootPath, "node_modules/@plone/volto");
let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');

Object.keys(pathsConfig).forEach((pkg) => {
if (pkg === "@plone/volto") {
Object.keys(pathsConfig).forEach(pkg => {
if (pkg === '@plone/volto') {
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`;
}
});
const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
const reg = new AddonConfigurationRegistry(projectRootPath);

// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
const addonAliases = Object.keys(reg.packages).map((o) => [
const addonAliases = Object.keys(reg.packages).map(o => [
o,
reg.packages[o].modulePath,
]);


module.exports = {
extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`,
settings: {
"import/resolver": {
'import/resolver': {
alias: {
map: [
["@plone/volto", "@plone/volto/src"],
['@plone/volto', '@plone/volto/src'],
...addonAliases,
["@package", `${__dirname}/src`],
["~", `${__dirname}/src`],
['@package', `${__dirname}/src`],
['~', `${__dirname}/src`],
],
extensions: [".js", ".jsx", ".json"],
extensions: ['.js', '.jsx', '.json'],
},
"babel-plugin-root-import": {
rootPathSuffix: "src",
'babel-plugin-root-import': {
rootPathSuffix: 'src',
},
},
},
};

43 changes: 21 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ GREEN=`tput setaf 2`
RESET=`tput sgr0`
YELLOW=`tput setaf 3`

ifeq ($(wildcard ./project),)
NODE_MODULES = "../../../node_modules"
else
NODE_MODULES = "./project/node_modules"
endif

project:
npm install -g yo
npm install -g @plone/generator-volto
Expand All @@ -35,64 +41,57 @@ start-backend-docker: ## Starts a Docker-based backend
docker run -it --rm --name=plone -p 8080:8080 -e SITE=Plone -e ADDONS="kitconcept.volto" -e ZCML="kitconcept.volto.cors" plone

.PHONY: test
test:
test: ## Run jest tests
docker pull plone/volto-addon-ci:alpha
docker run -it --rm -e NAMESPACE="@eeacms" -e GIT_NAME="${DIR}" -e RAZZLE_JEST_CONFIG=jest-addon.config.js -v "$$(pwd):/opt/frontend/my-volto-project/src/addons/${DIR}" -e CI="true" plone/volto-addon-ci:alpha

.PHONY: test-update
test-update:
test-update: ## Update jest tests snapshots
docker pull plone/volto-addon-ci:alpha
docker run -it --rm -e NAMESPACE="@eeacms" -e GIT_NAME="${DIR}" -e RAZZLE_JEST_CONFIG=jest-addon.config.js -v "$$(pwd):/opt/frontend/my-volto-project/src/addons/${DIR}" -e CI="true" plone/volto-addon-ci:alpha yarn test src/addons/${DIR}/src --watchAll=false -u

.PHONY: help
help: ## Show this help.
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"


ifeq ($(wildcard ./project),)
NODE_MODULES = "../../../node_modules"
else
NODE_MODULES = "./project/node_modules"
endif

.PHONY: stylelint
stylelint:
stylelint: ## Stylelint
$(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}'

.PHONY: stylelint-overrides
stylelint-overrides:
$(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides'

.PHONY: stylelint-fix
stylelint-fix:
stylelint-fix: ## Fix stylelint
$(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}' --fix
$(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' --fix

.PHONY: prettier
prettier:
prettier: ## Prettier
$(NODE_MODULES)/.bin/prettier --single-quote --check 'src/**/*.{js,jsx,json,css,less,md}'

.PHONY: prettier-fix
prettier-fix:
prettier-fix: ## Fix prettier
$(NODE_MODULES)/.bin/prettier --single-quote --write 'src/**/*.{js,jsx,json,css,less,md}'

.PHONY: lint
lint:
lint: ## ES Lint
$(NODE_MODULES)/eslint/bin/eslint.js --max-warnings=0 'src/**/*.{js,jsx}'

.PHONY: lint-fix
lint-fix:
lint-fix: ## Fix ES Lint
$(NODE_MODULES)/eslint/bin/eslint.js --fix 'src/**/*.{js,jsx}'

.PHONY: i18n
i18n:
i18n: ## i18n
rm -rf build/messages
NODE_ENV=development $(NODE_MODULES)/.bin/i18n --addon

.PHONY: cypress-run
cypress-run:
cypress-run: ## Run cypress integration tests
NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run

.PHONY: cypress-open
cypress-open:
cypress-open: ## Open cypress integration tests
NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open

.PHONY: help
help: ## Show this help.
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
1 change: 1 addition & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = defineConfig({
setupNodeEvents(on, config) {
// e2e testing node events setup code
require('@cypress/code-coverage/task')(on, config);
require('cypress-fail-fast/plugin')(on, config);
return config;
},
baseUrl: 'http://localhost:3000',
Expand Down
3 changes: 3 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import './commands';
//Generate code-coverage
import '@cypress/code-coverage/support';

// Fail Fast
import "cypress-fail-fast";

export const slateBeforeEach = (contentType = 'Document') => {
cy.autologin();
cy.createContent({
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@
"react-tooltip": "4.2.21"
},
"devDependencies": {
"@plone/scripts": "2.0.0",
"@cypress/code-coverage": "^3.9.5",
"md5": "^2.3.0",
"babel-plugin-transform-class-properties": "^6.24.1"
"@plone/scripts": "*",
"@cypress/code-coverage": "^3.10.0",
"cypress-fail-fast": "^5.0.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"md5": "^2.3.0"
},
"scripts": {
"release": "release-it",
Expand Down

0 comments on commit dc81381

Please sign in to comment.