
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
@hackney/mtfh-cypress
Advanced tools
@hackney/mtfh-cypress
This package is intended to be used in conjuction with a live environment that uses import-maps to resolve micro-frontends. It will stub an import-map with the url defined in the env. This allows us to test a local MFE against an environment without deploying, while having access to the entire environment.
Lifecycle:
${DEV_URL}/import-map.json
and store the output.yarn add @hackney/mtfh-cli
yarn add dotenv cypress -D
This library provides both a configuration plugin as well as a collection of hooks and commands. Plugins run in the node context within cypress and commands run in the browser, so we have to wire them up separately.
In cypress/plugins/index.js
const { configPlugin } = require("@hackney/mtfh-cypress/plugin");
module.exports = (on, config) => {
let mtfhConfig = configPlugin(on, config);
return mtfhConfig;
};
Create a .env
file in the root of your project.
CYPRESS_ENVIRONMENT=development
CYPRESS_BASE_URL=https://manage-my-home-development.hackney.gov.uk
CYPRESS_AUTH_TOKEN=token
You'll want to configure these variables in your circle ci pipeline to match your environment.
In cypress.json
{
"env": {
"DEV_URL": "http://localhost:9000",
}
}
In cypress/support/index.js
import "@hackney/mtfh-cypress";
This will import the @testing-library/cypress
commands to mirror the FE unit testing
approaches we use.
Commands added:
// Visit a url with authenticated credentials
cy.authVisit("/", options);
// Visit a url as a guest (unauthenticated)
cy.guestVisit("/", options);
// Get the value of a feature toggle
cy.hasToggle("MMH.CreateTenure").then((bool) => {});
// Skip test on ENVIRONMENT env
cy.skipOnEnv("development");
// Skip test on Feature Toggle
cy.skipOnToggle("MMH.CreateTenure", true);
To skip a collection of tests encapsulate the tests in a describe
describe('Collection of tests', () => {
before(() => {
cy.skipOnToggle('MMH.CreateTenure', true);
})
it('creates a tenure', () => {
...
})
})
We provide commands for testing performance as well as accessibility.
// Equalvalent of testing for mobile
cy.lighthouse({
seo: 0,
"best-practices": 100,
accessibility: 100,
performance: 80,
});
// Runs lighthouse with the desktop config
cy.lighthouseDesktop({
seo: 0,
"best-practices": 100,
accessibility: 100,
performance: 80,
});
// Runs accessibility testing, using pa11y
cy.pa11y({ actions: ["wait for element h1 to be added"] });
NB: It's important to note that Lighthouse's performance metrics can't really be taken as an indication of the actual report. This plugin is intended to run a local version of the micro-frontend so we can test against it before deploying. Ie. we will be testing against an app that isn't served by our architecture. You can however use it as a quality gate to ensure new changes don't reduce the scores. We recommend manual performance testing in live environments to get real world values.
This library comes with the following preconfigured:
The config plugin will override a few cypress.json
defaults that align to the
requirements more closely.
Such as:
{
"retries": {
"runMode": 2,
"openMode": 0,
},
"chromeWebSecurity": false,
"defaultCommandTimeout": 10000,
}
FAQs
Cypress helpers fpr LBH Modern Tools for Housing
We found that @hackney/mtfh-cypress demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.