This is a simple React application that fetches and displays the most popular articles from the New York Times. It allows users to view a list of articles and see detailed information when an article is clicked.
- Fetch and display the most popular articles from the New York Times.
- View detailed information about an article.
- Error handling for API calls.
- Tests for components and API calls.
- End to End testing for pages
- Node.js (v16 or later)
- An NY Times API key (sign up here)
- Clone the repository:
git clone https://github.com/aayanqazi/news-article.git
cd news-article
- Install Dependencies:
npm install (if you are facing error so try to use npm install --force)
- Set up environment variables: Create a .env file in the root directory with the following content
REACT_APP_API_KEY=your-nyt-api-key
To start the development server, run
npm start
This will open the app in your default web browser at http://localhost:3000.
To build the app for production, run
npm run build
This will create an optimized production build in the build folder.
To run the tests, use the following command
npm run test
To generate test coverage reports, run
npm run test:coverage
This will generate a coverage report in the coverage folder.
To open the Cypress test runner, run:
npm run cy
To run Cypress tests in headless mode using Chrome, run:
npm run cy:run
To lint your JavaScript files, use the following command:
npm run lint
To fix linting issues automatically, run:
npm run lint:fix