Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,52 @@ on:
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read # to checkout code
steps:
- name: ⬇️ Get latest code
uses: actions/checkout@v6

- name: ⬇️ Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: ⬇️ Get Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: "pnpm"

- name: 📦 Install dependencies
run: pnpm install

- name: 🧪 Run tests with coverage
run: pnpm run test:ci

- name: 📊 Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: ./coverage/ngx-back-button/lcov.info
flags: unittests
name: ngx-back-button-coverage
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}

publish:
runs-on: ubuntu-latest
needs: test
if: github.ref_name == 'main'
permissions:
contents: write # to be able to publish a GitHub release
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ A library for handling a proper angular back button capability
[![npm version](https://img.shields.io/npm/v/ngx-back-button.svg)](https://www.npmjs.com/package/ngx-back-button)
![npm bundle size](https://img.shields.io/bundlephobia/min/ngx-back-button)
![npm](https://img.shields.io/npm/dm/ngx-back-button)
[![codecov](https://codecov.io/gh/rbalet/ngx-back-button/branch/main/graph/badge.svg)](https://codecov.io/gh/rbalet/ngx-back-button)

1. Handle Browser history
2. Handle `Fallback` when clicking on the back button when not routed yet
Expand Down Expand Up @@ -179,6 +180,34 @@ export class MyComponent {

For most use cases, it's recommended to use the directive, which handles this automatically.

## Development

### Running Tests

The library uses Vitest for testing with comprehensive unit tests achieving 100% code coverage.

Run tests in watch mode:
```sh
npm test
```

Run tests once with coverage:
```sh
npm run test:ci
```

Run tests with UI:
```sh
npm run test:ui
```

### Building

Build the library:
```sh
npm run build
```

## Authors and acknowledgment
* Maintainer [Raphaël Balet](https://github.com/rbalet)
* Inspired by [Nils Mehlhirn](https://nils-mehlhorn.de/posts/angular-navigate-back-previous-page/)
Expand Down
6 changes: 0 additions & 6 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
}
},
"defaultConfiguration": "production"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"tsConfig": "projects/ngx-back-button/tsconfig.spec.json"
}
}
}
},
Expand Down
23 changes: 23 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
codecov:
require_ci_to_pass: true

coverage:
precision: 2
round: down
range: "70...100"

status:
project:
default:
target: auto
threshold: 1%
base: auto
patch:
default:
target: auto
threshold: 1%

comment:
layout: "reach,diff,flags,tree"
behavior: default
require_changes: false
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
"start": "ng serve",
"build": "ng build ngx-back-button --configuration production",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"test:ci": "ng test ngx-back-button --watch=false --code-coverage --no-progress --browsers=ChromeHeadless",
"test": "vitest",
"test:ci": "vitest run --coverage",
"test:ui": "vitest --ui",
"deploy": "ng build ngx-back-button --configuration production && pnpm run copy-files && pnpm publish ./dist/ngx-back-button",
"copy-files": "cp README.md dist/ngx-back-button && cp LICENSE dist/ngx-back-button"
},
Expand All @@ -42,27 +43,27 @@
"@angular/platform-browser-dynamic": "21.2.0",
"@angular/router": "21.2.0",
"rxjs": "7.8.2",
"tslib": "2.8.1"
"tslib": "2.8.1",
"zone.js": "^0.16.1"
},
"devDependencies": {
"@analogjs/vite-plugin-angular": "^2.3.1",
"@angular-devkit/build-angular": "21.2.0",
"@angular/cli": "21.2.0",
"@angular/compiler-cli": "21.2.0",
"@angular/platform-server": "^21.2.0",
"@semantic-release/commit-analyzer": "^13.0.1",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "12.0.6",
"@semantic-release/npm": "^13.1.5",
"@semantic-release/release-notes-generator": "^14.1.0",
"@types/jasmine": "5.1.15",
"jasmine-core": "5.13.0",
"karma": "6.4.4",
"karma-chrome-launcher": "3.2.0",
"karma-coverage": "2.2.1",
"karma-jasmine": "5.1.0",
"karma-jasmine-html-reporter": "2.2.0",
"@vitest/coverage-v8": "^4.0.18",
"@vitest/ui": "^4.0.18",
"jsdom": "^28.1.0",
"ng-packagr": "21.2.0",
"semantic-release": "25.0.3",
"typescript": "5.9.3"
"typescript": "5.9.3",
"vitest": "^4.0.18"
},
"release": {
"branches": [
Expand Down
Loading