This is a simple project that allows a user to check if a word is a palindrome.
This project was bootstrapped with typescript and create-react-app. npx create-react-app .
The dependencies required are all included in the package.json
file. They will all be installed by running the npm install
command.
To start the project run npm start
.
click the link below
Open Ifeanyi-palindrome-app to view it in the browser.
Every time I use expect("anything").toBeInTheDocument() on test file, when running the test I get:
TypeError: expect(...).toBeInTheDocument is not a function
solution
- install jest-dom
npm i --save-dev @testing-library/jest-dom
- create a
setupTests.js
file in<rootDir>/src
and putimport '@testing-library/jest-dom';
in your file
source
stackoverflow question #1 - react-testing-library why is toBeInTheDocument() not a function
When I tried to render the component Input.jsx
while running the test I get:
expect(received).toBe(expected) // Object.is equality
Expected: "racecar"
Received: ""
solution
The component recieves props and I had to pass in those props as well while testing
const props = {
setWord: jest.fn(),
handleSubmit: jest.fn(),
stop: "racecar",
}
render(<Input {...props} />);
source
stackoverflow question #1 - Test input Search box with React testing library
I wanted to trigger user input, so I chose to use @testing-library/user-event
userEvent.type(inputEl, "racecar");
await waitFor(() => {
expect(inputEl.value).toBe("racecar");
})
source
This project was created from scratch and was not linked to the remote GitHub repository, so I started the process of setting a remote-tracking
branch for my local repo. This is because I lost my .git
sub-directory (somehow)
action
git add . && git commit -m "switch branch, write unit test" && git push
error
fatal: The current branch main has no upstream branch.
solution
git push --set-upstream origin main
action
git push --set-upstream origin main
error
fatal: failed to push some refs to github.com/**
solution
git pull --rebase origin main
action
git pull
error
There is no tracking information for the current branch, If you wish to set tracking information for this branch you can do so with:
solution
git branch --set-upstream-to=origin/main main
error
fatal: refusing to merge unrelated histories
solution
git pull origin main --allow-unrelated-histories
FINALLY
git pull --rebase origin main
git add .
git commit -m "resolve merge conflicts"
git push
Attention
When a merge conflict occurs , you can open individual file. You will get "<<<<<<< or >>>>>>>" symbols. These refer to your changes and the changes present on remote. You can manually edit the part that is requires. after that save the file and then do : git add
The merge conflicts will be resolved.
Resources
Dealing with non-fast-forward errors
How to fix ‘failed to push some refs to’ Git errors
Pulling is not possible because you have unmerged files
Git refusing to merge unrelated histories on rebase
Git push rejected "non-fast-forward"
What does "Git push non-fast-forward updates were rejected" mean?
"refusing to merge unrelated histories" failure while pulling to recovered repository