Skip to content

Commit

Permalink
Merge pull request #42 from jams2/feature/snapshot-tests
Browse files Browse the repository at this point in the history
Use snapshot tests instead of HTML fixtures
  • Loading branch information
jams2 committed Jun 7, 2023
2 parents f1f5c26 + 20f6d46 commit 02488bc
Show file tree
Hide file tree
Showing 176 changed files with 2,645 additions and 2,692 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
id: setup-python
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: snok/install-poetry@v1
Expand All @@ -43,11 +44,15 @@ jobs:
uses: actions/cache@v2
with:
path: .venv
key: ${{ runner.os }}-python-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/poetry.lock') }}
key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- if: steps.poetry-cache.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- run: poetry run flake8 tbxforms tests
- run: poetry run isort tbxforms tests --check-only --diff
- run: poetry run black tbxforms tests --check
# Enforce strict formatting on the snapshots
- run: poetry run djlint --check tests
# Lint the project's templates
- run: poetry run djlint tbxforms
- run: poetry run pytest
- run: poetry build
14 changes: 13 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
- id: debug-statements
- id: detect-private-key
- repo: https://github.com/timothycrosley/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
- repo: https://gitlab.com/pycqa/flake8
Expand All @@ -35,3 +35,15 @@ repos:
rev: v2.3.2
hooks:
- id: prettier
- repo: local
hooks:
- id: djlint-templates
name: Lint project templates
language: python
files: tbxforms/.*\.html$
entry: djlint
- id: djlint-snapshots
name: Check snapshot formatting
language: python
files: tests/.*\.html$
entry: djlint --check
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
.tox
*.html
dist
tests
tests
.mypy_cache
14 changes: 5 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
## Unreleased

---

## [vx.y.z](https://github.com/torchbox/tbxforms/releases/tag/x.y.z) (Template: https://keepachangelog.com/en/1.0.0/)

### Added

### Changed

### Fixed
- Use snapshot testing plugin (syrupy) for component rendering tests instead of HTML fixtures

### Removed
### Added

### How to upgrade
- Template linting to CI using `djlint`
- Snapshot formatting check to CI using `djlint`
- Autoformatting of snapshots using `djlint`
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ pre-commit install
npm install
```

### Python testing

Run the Python tests with `poetry run pytest`.

If your changes cause snapshot tests to fail, verify that the changes you have caused are expected. Update the snapshots with `poetry run pytest --snapshot-update`.

### Publishing

1. `pre-commit` - run linters
Expand Down

0 comments on commit 02488bc

Please sign in to comment.