import { expect } from 'chai';
import fs from 'fs';
import path from 'path';
describe('Cypress installation verification', () => {
const projectDir = process.cwd();
const nodeModulesCypressPath = path.join(projectDir, 'node_modules', 'cypress');
const packageJsonPath = path.join(projectDir, 'package.json');
it('should have cypress folder inside node_modules', () => {
const exists = fs.existsSync(nodeModulesCypressPath);
expect(exists).to.be.true;
});
it('should list cypress as a dependency in package.json', () => {
const packageJsonRaw = fs.readFileSync(packageJsonPath, 'utf-8');
const packageJson = JSON.parse(packageJsonRaw);
const dependencies = packageJson.dependencies || {};
expect(dependencies).to.have.property('cypress');
});
});This test suite checks if Cypress is installed correctly after running npm install cypress.
First, it uses Node.js fs.existsSync to check if the node_modules/cypress folder exists, which means Cypress files are present.
Second, it reads package.json and parses it as JSON to verify that Cypress is listed under dependencies. This confirms npm recorded Cypress as a project dependency.
We use chai assertions for clear pass/fail results. The tests run in the current working directory, assuming the commands were run there.