我已阅读有关此问题的所有帖子,但没有一个对我有用。
我有一个应用程序模块,一个路由模块,没有其他“模块”。我发现的是...
我的路线是这样...
{path: 'hellocontent', component: ContentHelloWorldComponentComponent,
pathMatch: 'full', outlet: 'helloc'},
Run Code Online (Sandbox Code Playgroud)
路由器链接是...
<a [routerLink]="[{ outlets: { helloc: ['hellocontent'] } }]">action</a>.
Run Code Online (Sandbox Code Playgroud)
我的路由器插座是...
<router-outlet name="helloc"></router-outlet>
<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)
该路由器链接在标准的 angular app.component.html 中完美运行,但不适用于任何其他组件。它总是导致“错误:无法匹配任何路由。URL 段:”。
一旦我删除了命名插座,并将 routerLink 更改为...
<a routerLink="hellocontent">action</a>在应用程序组件或<a routerLink="/hellocontent">action</a>另一个组件中,它就可以完美运行,但只能在主插座中使用。
因为它可能很重要,我链接的组件当然也在它们自己的路由中定义,例如......
{path: 'hello-world', component: HelloWorldComponentComponent}
Run Code Online (Sandbox Code Playgroud)
这是预期的行为,即命名插座只能从它们定义的组件内访问吗?奇怪的是,我的大部分 html 包装器都在 app.component.html 中,但是除了主插座之外的任何东西都不能从另一个组件中工作。
我使用 git 的实用程序创建了以下目录树。
./git-logbranch/git-logbranch_test.go
./git-logbranch/git-logbranch.go
./git-logbranch/go.mod
./git-issue/git-issue_test.go
./git-issue/go.mod
./git-issue/git-issue.go
./main.go
./go.mod
Run Code Online (Sandbox Code Playgroud)
我读过几篇文章,说“./...”将自动在所有子文件夹中运行测试,但实际上并没有这样做。这就是我正在运行的内容和得到的输出:
$ go test ./...
? main [no test files]
Run Code Online (Sandbox Code Playgroud)
以下是子文件夹的一些输出示例。如您所见,各个测试有效:
$ go test ./...
ok git_logbranch 0.001s
$ go test ./...
ok git_issue (cached)
Run Code Online (Sandbox Code Playgroud)
关于如何同时运行所有这些测试有什么想法吗?
显然我根本不理解测试库。它们具有“单击”功能,但似乎没有用于从选择元素中选择简单下拉选项的功能。这是失败的,表示选择了 0,而不是预期的 1。我如何使选择工作?
import React from "react";
import {render} from '@testing-library/react'
import {screen} from '@testing-library/dom'
let container: any;
beforeEach(() => {
container = document.createElement('div');
document.body.appendChild(container);
});
afterEach(() => {
document.body.removeChild(container);
container.remove();
container = null;
});
it('AddRental should display', () => {
render(<select name="town" data-testid="town" className="form-control"
aria-label="Select the Town">
<option value="0">--Town--</option>
<option value="1">My town</option>
<option value="2">Your Town</option>
<option value="3">The other town</option>
</select>, {container});
const dropdown = screen.getByTestId('town');
expect(dropdown.value)
.toBe('0');
dropdown.click();
const athabascaOption = screen.getByText('My town');
athabascaOption.click();
const byTestId = screen.getByTestId('town');
expect(byTestId.value) …Run Code Online (Sandbox Code Playgroud)