-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Morten Ramfjords Workflow PR #401
base: master
Are you sure you want to change the base?
Conversation
… package.json, installed and configured husky git hooks
Create main.yml
Create autoUnitTesting.yml
Create e2e-test.yml
WalkthroughThis pull request introduces a comprehensive suite of testing and linting tools to the project. It includes ESLint for static code analysis, Husky for pre-commit hooks, GitHub Actions for automated unit and end-to-end testing, and Cypress for end-to-end testing. The changes also include test cases for login and logout functionalities, both for unit tests and end-to-end tests. Changes
Uplevel your code reviews with CodeRabbit ProCodeRabbit ProIf you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files selected (13)
- .eslintrc.json (1)
- .github/workflows/autoUnitTesting.yml (1)
- .github/workflows/e2e-test.yml (1)
- .gitignore (1)
- .husky/pre-commit (1)
- README.md (1)
- cypress.config.js (1)
- cypress/e2e/3-e2e-testing-ca/loginSpec.cy.js (1)
- cypress/e2e/3-e2e-testing-ca/logoutSpec.cy.js (1)
- cypress/support/commands.js (1)
- cypress/support/e2e.js (1)
- src/tests/login.test.js (1)
- src/tests/logout.test.js (1)
Files ignored due to filter (4)
- babel.config.json
- cypress/fixtures/example.json
- package-lock.json
- package.json
Files skipped from review due to trivial changes (9)
- .github/workflows/autoUnitTesting.yml
- .github/workflows/e2e-test.yml
- .gitignore
- .husky/pre-commit
- README.md
- cypress.config.js
- cypress/support/commands.js
- cypress/support/e2e.js
- src/tests/login.test.js
Review comments generated (6)
- Review: 3
- LGTM: 3
Tips
Chat with CodeRabbit Bot (@coderabbitai
)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitai
in a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignore
anywhere in the PR description to pause further reviews from the bot.
cy.get(window.localStorage.getItem("token")).should("not.be.empty"); | ||
cy.get(window.localStorage.getItem("profile")).should("not.be.empty"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing localStorage
directly in Cypress commands is not recommended. Instead, use the cy.window()
command to access localStorage
. This ensures that you're accessing the same localStorage
object as your application.
- cy.get(window.localStorage.getItem("token")).should("not.be.empty");
- cy.get(window.localStorage.getItem("profile")).should("not.be.empty");
+ cy.window().its('localStorage.token').should('exist');
+ cy.window().its('localStorage.profile').should('exist');
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:prettier/recommended" | ||
], | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"**/*.test.js", | ||
"**/*.cy.js" | ||
], | ||
"env": { | ||
"jest": true, | ||
"cypress/globals": true | ||
}, | ||
"plugins": [ | ||
"prettier", | ||
"jest", | ||
"cypress" | ||
], | ||
"extends": [ | ||
"plugin:jest/recommended", | ||
"plugin:cypress/recommended" | ||
], | ||
"rules": { | ||
"jest/prefer-expect-assertions": "off", | ||
"cypress/no-unnecessary-waiting": "off", | ||
"no-unused-vars": "off" | ||
} | ||
} | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"rules": {} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ESLint configuration looks good overall, but there's a minor issue. It's a best practice to always end your files with a newline. This is because some tools like cat
, sed
, awk
, etc., might not recognize or have issues processing the last line if it doesn't end with a newline.
"rules": {}
- 42: }
+ 42: }\n
Also, you've turned off the rule no-unused-vars
in your test files (line 33). While this can sometimes be necessary in test files, be cautious as it could potentially hide bugs related to unused variables in your tests. Consider enabling it and using ignore comments (// eslint-disable-next-line no-unused-vars
) on a case-by-case basis where necessary.
cy.get(window.localStorage.getItem("token")).should("not.be.empty"); | ||
cy.get(window.localStorage.getItem("profile")).should("not.be.empty"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way you're trying to access localStorage items is incorrect. cy.get
is used to get DOM elements, not localStorage items. You should use cy.window().its('localStorage.token')
and cy.window().its('localStorage.profile')
instead.
- cy.get(window.localStorage.getItem("token")).should("not.be.empty");
- cy.get(window.localStorage.getItem("profile")).should("not.be.empty");
+ cy.window().its('localStorage.token').should('exist');
+ cy.window().its('localStorage.profile').should('exist');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rabbit is telling the truth
"overrides": [ | ||
{ | ||
"files": [ | ||
"**/*.test.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should have one override for each testing platform, instead of merging these together.
|
||
it("The user can login with the login form with valid credentials", () => { | ||
cy.get("#loginEmail").type("Ramsnes@noroff.no"); | ||
cy.get("#loginPassword").type("Marmea88"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Real data should be protected in .env and secrets
cy.get(window.localStorage.getItem("token")).should("not.be.empty"); | ||
cy.get(window.localStorage.getItem("profile")).should("not.be.empty"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rabbit is telling the truth
@@ -1,20 +1,52 @@ | |||
{ | |||
"name": "css-frameworks-ca", | |||
"version": "1.0.0", | |||
"version": "0.0.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"version": "0.0.3", | |
"version": "1.0.3", |
Version numbers never go backwards
Summary by CodeRabbit
login
andlogout
functions to verify their correct behavior.