Skip to content
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

Feature/setup tests #38

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
500c7bb
created first snapshot tests for atoms
MartinSkatvedt Jan 13, 2021
400d44b
setup snapshot tests for atoms
MartinSkatvedt Jan 13, 2021
56e4e08
added tests to actions here
MartinSkatvedt Jan 13, 2021
462b3c7
fixing the lint errors that make netlify not work
MartinSkatvedt Jan 13, 2021
e8dffb9
added snapshot tests for categorybar
MartinSkatvedt Jan 13, 2021
677f46e
added one more unit test
MartinSkatvedt Jan 14, 2021
98012d6
changed from js to tsx for tests
MartinSkatvedt Jan 17, 2021
ad30707
removed wrongly placed file
MartinSkatvedt Jan 17, 2021
9550c27
wrote snapshot tests and changed a p-tag to a span-tag in register.tsx
MartinSkatvedt Jan 17, 2021
8693bcb
Merge branch 'main' into feature/setupTests
MartinSkatvedt Jan 17, 2021
221a117
deleted olcoins files
MartinSkatvedt Jan 17, 2021
b7dcf97
added render test to navabr
MartinSkatvedt Jan 17, 2021
70e2c35
added render test to Shopitem along with a mochProduct
MartinSkatvedt Jan 17, 2021
b28088c
added render test to Basketwindow, which uses context
MartinSkatvedt Jan 17, 2021
2ce5b41
added integration test to basketWindow
MartinSkatvedt Jan 17, 2021
267c65b
fixed typo in importing
MartinSkatvedt Jan 17, 2021
563281c
fixed a issue with modal root not rendering
MartinSkatvedt Jan 18, 2021
38af3a0
lint
MartinSkatvedt Jan 18, 2021
edeaec5
added render test to basketitem
MartinSkatvedt Jan 18, 2021
92ded4b
moved context stuff to setupTests
MartinSkatvedt Jan 19, 2021
8da4267
add
MartinSkatvedt Jan 20, 2021
9da4e03
added snapshot test to errormodal
MartinSkatvedt Jan 20, 2021
d9a8e90
added some new snapshot tests for modals
MartinSkatvedt Jan 20, 2021
0fe7cb6
added Storepage snapshot test
MartinSkatvedt Jan 20, 2021
56a3003
added snapshot tests for app
MartinSkatvedt Jan 20, 2021
e66ef11
added snapshot test to loginpage
MartinSkatvedt Jan 22, 2021
f27ffea
removed .vscode file
MartinSkatvedt Jan 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"endOfLine": "auto"
}
],
"no-non-null-assertion": 0,
"@typescript-eslint/no-non-null-assertion": "off"
"@typescript-eslint/no-non-null-assertion": "off",
"no-non-null-assertion": 0
}
}
11 changes: 6 additions & 5 deletions .github/workflows/lint.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# This is a basic workflow to help you get started with Actions

name: Lint Action
name: Lint and Testing
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand All @@ -19,9 +19,10 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Install dependencies
run: npm ci
- name: Check linting
run: npm run lint

- name: Run tests
run: npm run test
4 changes: 0 additions & 4 deletions .vscode/settings.json

This file was deleted.

38 changes: 22 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0",
Expand Down Expand Up @@ -48,6 +47,8 @@
]
},
"devDependencies": {
"@testing-library/dom": "^7.29.4",
"@testing-library/react": "^11.2.3",
"@types/styled-components": "^5.1.4",
"@typescript-eslint/eslint-plugin": "^4.6.1",
"@typescript-eslint/parser": "^4.6.1",
Expand Down
28 changes: 28 additions & 0 deletions src/__tests__/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from "react";
import { render, cleanup } from "@testing-library/react";
import "@testing-library/jest-dom/extend-expect";
import App from "../App";
import { StateContext } from "state/state";
import { fullContext, mockEmptyContext } from "setupTests";

afterEach(cleanup);

describe("Snapshot tests for app", () => {
it("Should match snapshot(store)", () => {
const { asFragment } = render(
<StateContext.Provider value={fullContext}>
<App />
</StateContext.Provider>
);
expect(asFragment()).toMatchSnapshot();
});

it("Should match snapshot(login)", () => {
const { asFragment } = render(
<StateContext.Provider value={mockEmptyContext}>
<App />
</StateContext.Provider>
);
expect(asFragment()).toMatchSnapshot();
});
});
Loading