NativeScript - how to get unit tests to work properly?
@NathanWalker đang làm issue này rồi.
Từ ngày 5/6/2020.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
I'm writing an app with NativeScript 6+ and Angular 8+.
I'm trying to write some unit tests and get them up and running.
I have read the documentation on unit testing: https://docs.nativescript.org/tooling/testing/testing
I followed the directions there for setting up the tests and using TestBed. My tests are not working and throwing errors.
Here is my repository: https://github.com/aubrey-fowler/NativeScriptUnitTests
Questions:
- The documentation only shows an example of how to write a test for a component. How do I write a test for a service? I also need to use TestBed for this because my service has dependency injection.
- My tests are throwing errors. Why and how can I fix them?
Errors:
no reachable hosts
on my Android phone
code snippet:
import { ItemsComponent } from '../app/item/items.component';
import {
nsTestBedAfterEach,
nsTestBedBeforeEach,
nsTestBedRender
} from 'nativescript-angular/testing';
describe('ItemsComponent Test', () => {
beforeEach(nsTestBedBeforeEach([ItemsComponent]));
afterEach(nsTestBedAfterEach(false));
it('should be defined', () => {
nsTestBedRender(ItemsComponent).then((fixture) => {
fixture.detectChanges();
const component = fixture.componentInstance;
expect(component).toBeTruthy;
});
});
});
- Ngôn ngữ chính
- JavaScript
- Star
- 1.1k
- Fork
- 204
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 8
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NativeScript/nativescript-cli
-
in-progress
NativeScript/nativescript-cli#6140 · 2 bình luận · 1 người được giao ·
-
NativeScript/nativescript-cli#6090 · 1 người được giao ·
-
in progress
NativeScript/nativescript-cli#6015 · 1 reaction · 1 người được giao ·
-
question
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
NativeScript/nativescript-cli#5992 · 5 bình luận ·
-
feature-pending-triage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
NativeScript/nativescript-cli#5975 ·
Tất cả issue của NativeScript/nativescript-cli
Issue tương tự
-
Edit: CW+ Đang mởchannels:edit check:passed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
스택 PR 머지 시 하위 PR base 재지정 단계 부재 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
idean3885/claude-ops-agent#521 ·
-
[Nytt ikon]: menu-search Đang mởforespørsel 🥰 ikoner 🖼 nytt ✨
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
avniproject/avni-client#2135 ·
-
automated broken-link
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100