karma jasmine

我们的目标 ( Our goal )

In this tutorial we will be building and testing an employee directory for a fictional company. This directory will have a view to show all of our users along with another view to serve as a profile page for individual users. Within this part of the tutorial we'll focus on building the service and its tests that will be used for these users.

在本教程中,我们将为虚构的公司构建和测试员工目录。 该目录将具有一个视图,以显示我们的所有用户,以及另一个视图,以用作个人用户的个人资料页面。 在本教程的这一部分中,我们将专注于构建将用于这些用户的服务及其测试。

In following tutorials, we'll populate the user profile page with an image of the user's favorite Pokemon using the Pokeapi and learn how to test services that make HTTP requests.

在以下教程中,我们将使用Pokeapi使用用户喜欢的Pokemon的图像填充用户个人资料页面,并了解如何测试发出HTTP请求的服务。

你应该知道什么 ( What you should know )

The primary focus for this tutorial is testing so my assumption is that you're comfortable working with TypeScript and Angular applications. As a result of this I won't be taking the time to explain what a service is and how it's used. Instead, I'll provide you with code as we work through our tests.

本教程的主要重点是测试,因此我的假设是您可以轻松使用TypeScript和Angular应用程序。 因此,我不会花时间解释什么是服务以及如何使用它。 相反,我们将在测试过程中为您提供代码。

为什么要测试? ( Why Test? )

From personal experience, tests are the best way to prevent software defects. I've been on many teams in the past where a small piece of code is updated and the developer manually opens their browser or Postman to verify that it still works. This approach (manual QA) is begging for a disaster.

从个人经验来看,测试是预防软件缺陷的最佳方法。 过去,我曾在许多团队中工作过,其中一小段代码被更新,开发人员手动打开他们的浏览器或Postman以验证其是否仍然有效。 这种方法(手动质量检查)正在引发灾难。

Tests are the best way to prevent software defects.

测试是预防软件缺陷的最佳方法。

As features and codebases grow, manual QA becomes more expensive, time consuming, and error prone. If a feature or function is removed does every developer remember all of its potential side-effects? Are all developers manually testing in the same way? Probably not.

随着功能和代码库的增长,手动质量检查变得更加昂贵,耗时且容易出错。 如果某个功能部件被删除,每个开发人员是否会记住其所有潜在的副作用? 是否所有开发人员都以相同方式手动测试? 可能不是。

The reason we test our code is to verify that it behaves as we expect it to. As a result of this process you'll find you have better feature documentation for yourself and other developers as well as a design aid for your APIs.

我们测试代码的原因是为了验证其行为是否符合我们的预期。 作为此过程的结果,您将发现自己和其他开发人员拥有更好的功能文档以及API的设计帮助。

为什么要因果报应? ( Why Karma? )

Karma is a direct product of the AngularJS team from struggling to test their own framework features with existing tools. As a result of this, they made Karma and have transitioned it to Angular as the default test runner for applications created with the Angular CLI.

Karma是AngularJS团队的直接产品,它努力使用现有工具测试其自身的框架功能。 结果,他们制作了Karma,并将其转换为Angular,以作为使用Angular CLI创建的应用程序的默认测试运行程序。

In addition to playing nicely with Angular, it also provides flexibility for you to tailor Karma to your workflow. This includes the option to test your code on various browsers and devices such as phones, tablets, and even a PS3 like the YouTube team.

除了可以很好地使用Angular,它还为您提供了灵活性,使您可以根据工作流程定制Karma。 这包括在各种浏览器和设备(例如手机,平板电脑,甚至YouTube团队等PS3)上测试代码的选项。

Karma also provides you options to replace Jasmine with other testing frameworks such as Mocha and QUnit or integrate with various continuous integration services like Jenkins, TravisCI, or CircleCI.

Karma还为您提供了用其他测试框架(例如Mocha和QUnit)替换Jasmine或与各种持续集成服务(例如Jenkins , TravisCI或CircleCI)集成的选项 。

Unless you add some additional configuration your typical interaction with Karma will be to run ng test in a terminal window.

除非您添加一些其他配置,否则与Karma的典型交互将是在终端窗口中运行ng test

为什么选择茉莉花? ( Why Jasmine? )

Jasmine is a behavior-driven development framework for testing JavaScript code that plays very well with Karma. Similar to Karma, it’s also the recommended testing framework within the Angular documentation as it's setup for you with the Angular CLI. Jasmine is also dependency free and doesn’t require a DOM.

Jasmine是一个行为驱动的开发框架,用于测试与Karma配合良好JavaScript代码。 与Karma相似,它也是Angular文档中推荐的测试框架,因为它是使用Angular CLI为您设置的。 Jasmine也是不受依赖的,并且不需要DOM。

As far as features go, I love that Jasmine has almost everything I need for testing built into it. The most notable example would be spies. A spy allows us to “spy” on a function and track attributes about it such as whether or not it was called, how many times it was called, and with which arguments it was called. With a framework like Mocha, spies are not built-in and would require pairing it with a separate library like Sinon.js.

就功能而言,我喜欢Jasmine内置了几乎所有测试所需的功能。 最著名的例子是间谍。 间谍使我们可以“监视”一个函数并跟踪有关它的属性,例如是否调用了该函数,调用了多少次以及调用了哪些参数。 使用Mocha之类的框架,间谍不是内置的,需要将其与Sinon.js之类的单独库配对。

The good news is that the switching costs between testing frameworks is relatively low with differences in syntax as small as Jasmine's toEqual() and Mocha's to.equal().

好消息是,测试框架之间的转换成本相对较低,语法差异小至Jasmine的toEqual()和Mocha的to.equal()

一个简单的测试示例 ( A Simple Test Example )

Imagine you had an alien servant named Adder who follows you everywhere you go. Other than being a cute alien companion Adder can really only do one thing, add two numbers together.

想象一下,您有一个名为Adder的外星仆人,他随处可见。 除了成为可爱的外星人伴侣,Adder真的只能做一件事,将两个数字加在一起。

To verify Adder's ability to add two numbers we could generate a set of test cases to see if Adder provides us the correct answer.

为了验证Adder能够将两个数字相加的能力,我们可以生成一组测试用例,以查看Adder是否为我们提供了正确的答案。

Within Jasmine, this would begin with what's referred to as a "suite" which groups a related set of tests by calling the function describe.

在Jasmine中,这将从所谓的“套件”开始,该套件通过调用函数describe来对一组相关的测试进行分组。

// A Jasmine suite
describe('Adder', () => {});

From here we could provide Adder with a set of test cases such as two positive numbers (2, 4), a positive number and a zero (3, 0), a positive number and a negative number (5, -2), and so on.

从这里我们可以为Adder提供一组测试用例,例如两个正数(2,4),一个正数和一个零(3,0),一个正数和一个负数(5,-2),以及以此类推。

Within Jasmine, these are referred to as "specs" which we create by calling the function it, passing it a string to describe the functionality that's being tested.

在Jasmine中,这些被称为“规范” ,我们通过调用it的函数,将其传递给一个字符串来描述正在测试的功能来创建。

describe('Adder', () => {// A jasmine specit('should be able to add two whole numbers', () => {expect(Adder.add(2, 2)).toEqual(4);});it('should be able to add a whole number and a negative number', () => {expect(Adder.add(2, -1)).toEqual(1);});it('should be able to add a whole number and a zero', () => {expect(Adder.add(2, 0)).toEqual(2);});
});

Within each spec we call expect and provide it what is referred to as an "actual"—the call site of our actual code. After the expectation, or expect, is the chained "matcher" function, such as toEqual, which the testing developer provides with the expected output of the code being tested.

在每个规范中,我们将expect称为“ expect并将其提供给“实际”,即我们实际代码的调用位置。 预期后,或expect ,是链接的“匹配”功能,诸如toEqual ,其检测显影剂的代码的预期输出被测试提供。

There are many other matchers available to us other than toEqual. You can see a full list within Jasmine's documentation.

除了toEqual之外,我们还有许多其他匹配器可用。 您可以在Jasmine的文档中看到完整列表。

Our tests aren't concerned with how Adder arrives at the answer. We only care about the answer Adder provides us. For all we know, this may be Adder's implementation of add.

我们的测试与Adder 如何得出答案无关。 我们只关心Adder为我们提供的答案。 就我们所知,这可能是Adder的add的实现。

function add(first, second) {if (true) { // why?if (true) { // why??if (1 === 1) { // why?!?1return first + second;}}}
}

In other words, we only care that Adder behaves as expected—we have no concern for Adder's implementation.

换句话说,我们只关心Adder的行为是否符合预期—我们不关心Adder的实现。

This is what makes a practice like test-driven development (TDD) so powerful. You can first write a test for a function and its expected behavior and get it to pass. Then, once it's passing, you can refactor your function to a different implementation and if the test is still passing, you know your function is still behaving as specified within your tests even with a different implementation. Adder's add function would be a good example!

这就是使像测试驱动开发(TDD)这样的实践如此强大的原因。 您可以首先为功能及其预期行为编写测试,然后使其通过。 然后,一旦通过,您就可以将函数重构为其他实现,并且如果测试仍在通过,则您知道即使使用其他实现,您的函数仍会按照测试中指定的方式运行。 加法器的add函数将是一个很好的例子!

角度设置 ( Angular setup )

We'll begin by creating our new application using the Angular CLI.

我们将从使用Angular CLI创建新应用程序开始。

ng new angular-testing --routing

Since we'll have multiple views in this application we use the --routing flag so the CLI automatically generates a routing module for us.

由于在此应用程序中将有多个视图,因此我们使用--routing标志,因此CLI会自动为我们生成一个路由模块。

From here we can verify everything is working correctly by moving into the new angular-testing directory and running the application.

在这里,我们可以移至新的angular-testing目录并运行该应用程序,以验证一切工作正常。

cd angular-testing
ng serve -o

You can also verify the application's tests are currently in a passing state.

您还可以验证应用程序的测试当前处于通过状态。

ngtest

添加主页 ( Adding a home page )

Before creating a service to populate our home page with users, we'll start by creating the home page.

在创建用于向用户填充我们的主页的服务之前,我们将从创建主页开始。

ng g component home

Now that our component has been created, we can update our routing module's (app-routing.module.ts) root path to HomeComponent.

现在已经创建了组件,我们可以将路由模块的( app-routing.module.ts )根路径更新为HomeComponent

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './home/home.component';const routes: Routes = [{ path: '', component: HomeComponent }
];@NgModule({imports: [RouterModule.forRoot(routes)],exports: [RouterModule]
})
export class AppRoutingModule { }

Run the application if it isn't already and you should now see "home works!" below the default template in app.component.html which was created by the CLI.

如果尚未运行该应用程序,则现在应该看到“家庭作品!” 在CLI所创建的app.component.html中的默认模板下面。

删除AppComponent测试 ( Removing AppComponent tests )

Since we no longer need the default contents of AppComponent, let's update it by removing some unnecessary code.

由于我们不再需要AppComponent的默认内容, AppComponent我们通过删除一些不必要的代码来对其进行更新。

First, remove everything in app.component.html so that only the router-outlet directive remains.

首先,删除app.component.html中的所有内容,以便仅保留router-outlet指令。

<router-outlet></router-outlet>

Within app.component.ts, you can also remove the title property.

app.component.ts ,您还可以删除title属性。

import { Component } from '@angular/core';@Component({selector: 'app-root',templateUrl: './app.component.html',styleUrls: ['./app.component.css']
})
export class AppComponent { }

Finally, you can update the tests in app.component.spec.ts by removing the two tests for some of the contents that were previously in app.component.html.

最后,您可以更新测试app.component.spec.ts通过移除两个测试对于一些在以前的内容app.component.html

import { async, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {beforeEach(async(() => {TestBed.configureTestingModule({imports: [RouterTestingModule],declarations: [AppComponent],}).compileComponents();}));it('should create the app', async(() => {const fixture = TestBed.createComponent(AppComponent);const app = fixture.debugElement.componentInstance;expect(app).toBeTruthy();}));
});

测试Angular服务 ( Testing an Angular service )

Now that our home page is set up we can work on creating a service to populate this page with our directory of employees.

现在我们的主页已经建立,我们可以创建一个服务来用我们的员工目录填充此页面。

ng gservice services/users/users

Here we've created our users service within a new services/users directory to keep our services away from the default app directory which can get messy quick.

在这里,我们在新的services/users目录中创建了users服务,以使我们的服务远离默认的app目录,因为该目录可能会很快变得混乱。

Now that our service is created, we can make a few small changes to the test file services/users/users.service.spec.ts.

现在,我们的服务已创建,我们可以对测试文件services/users/users.service.spec.ts进行一些小的更改。

I personally find injecting dependencies within it() to be a bit repetitive and harder to read as it's done in the default scaffolding for our test file as shown below:

我个人发现在it()注入依赖项有些重复并且更难阅读,因为它在测试文件的默认框架中完成,如下所示:

it('should be created', inject([TestService], (service: TestService) => {expect(service).toBeTruthy();
}));

With a few minor changes, we can move this into the beforeEach removing the duplication from each it.

有一些小的变化,我们可以将这个进入beforeEach从每个移除重复it

import { TestBed } from '@angular/core/testing';
import { UsersService } from './users.service';describe('UsersService', () => {let usersService: UsersService; // Add thisbeforeEach(() => {TestBed.configureTestingModule({providers: [UsersService]});usersService = TestBed.get(UsersService); // Add this});it('should be created', () => { // Remove inject()expect(usersService).toBeTruthy();});
});

In the code above, TestBed.configureTestingModule({}) sets up the service we want to test with UsersService set in providers. We then inject the service into our test suite using TestBed.get() with the service we want to test as the argument. We set the return value to our local usersService variable which will allow us to interact with this service within our tests just as we would within a component.

在上面的代码中, TestBed.configureTestingModule({})设置了我们要使用UsersService设置的UsersService进行测试的providers 。 然后,我们使用TestBed.get()将服务注入到我们的测试套件中, TestBed.get()要测试的服务作为参数。 我们将返回值设置为本地usersService变量,这将使我们能够像在组件内部一样在测试中与该服务进行交互。

Now that our test setup is restructured, we can add a test for an all method which will return a collection of users.

现在,我们的测试设置已经重组,我们可以为all方法添加一个测试,该测试将返回用户集合。

import { of } from 'rxjs'; // Add importdescribe('UsersService', () => {...it('should be created', () => {expect(usersService).toBeTruthy();});// Add tests for all() methoddescribe('all', () => {it('should return a collection of users', () => {const userResponse = [{id: '1',name: 'Jane',role: 'Designer',pokemon: 'Blastoise'},{id: '2',name: 'Bob',role: 'Developer',pokemon: 'Charizard'}];let response;spyOn(usersService, 'all').and.returnValue(of(userResponse));usersService.all().subscribe(res => {response = res;});expect(response).toEqual(userResponse);});});
});

Here we add a test for the expectation that all will return a collection of users. We declare a userResponse variable set to a mocked response of our service method. Then we use the spyOn() method to spy on usersService.all and chain .returnValue() to return our mocked userResponse variable wrapping it with of() to return this value as an observable.

在这里,我们添加了一个测试,期望all用户将返回用户集合。 我们声明一个userResponse变量设置为我们的服务方法的userResponse响应。 然后我们使用spyOn()方法来刺探usersService.all和链.returnValue()返回我们的嘲笑userResponse可变包裹它of()返回这个值作为可观察到的。

With our spy set, we call our service method as we would within a component, subscribe to the observable, and set its return value to response.

使用我们的间谍集,我们就像在组件内那样调用服务方法,订阅可观察对象,并将其返回值设置为response

Finally, we add our expectation that response will be set to the return value of the service call, userResponse.

最后,我们期望将response设置为服务调用的返回值userResponse

为什么要嘲笑? ( Why mock? )

At this point many people ask, "Why are we mocking the response?" Why did we provide our test a return value userResponse that we created ourselves, to manually set what’s being returned from our service? Shouldn’t the service call return the real response from the service, whether it's a hard-coded set of users or a response from an HTTP request?

在这一点上,许多人问:“我们为什么要嘲笑回应?” 为什么我们userResponse测试提供一个我们自己创建的返回值userResponse ,以手动设置服务返回的值? 服务调用是否应该返回服务的真实响应,无论是用户的硬编码集还是来自HTTP请求的响应?

This is a perfectly reasonable question to ask and one that can be hard to wrap your head around when you first begin testing. I find this concept is easiest to illustrate with a real world example.

这是一个完全合理的问题,当您开始进行测试时可能很难缠住头。 我发现用一个真实的例子最容易说明这个概念。

Imagine you own a restaurant and it’s the night before opening day. You gather everyone you’ve hired for a “test run” of the restaurant. You invite a few friends to come in and pretend they’re customers who will sit down and order a meal.

想象一下,您拥有一家餐厅,那是营业日的前一天晚上。 您聚集了为餐厅“试运行”而雇用的所有人。 您邀请几个朋友进来,假装他们是坐下来订餐的顾客。

No dishes will actually be served in your test run. You’ve already worked with your cooks and are satisfied they can make the dishes correctly. In this test run you want to test the transition from the customer ordering their dish, to the waiter sending that to the kitchen, and then the waiters fulfilling the kitchen’s response to the customer. This response from the kitchen may be one of a few options.

在您的测试运行中,实际上不会提供任何菜肴。 您已经与您的厨师一起工作过,并对他们可以正确制作菜肴感到满意。 在此测试运行中,您要测试从客户订购菜品到服务员将菜品发送到厨房,然后由服务员完成厨房对客户的响应的过渡。 厨房的这种回应可能是少数选择之一。

  1. The meal is ready.

    饭准备好了
  2. The meal is delayed.

    吃饭延迟了。
  3. The meal cannot be made. We ran out of ingredients for the dish.

    不能做饭。 我们的菜用完了。

If the meal is ready, the waiter delivers the meal to the customer. However, in the event that a meal is late or cannot be made, the waiter will have to go back to the customer, apologize, and potentially ask for a second dish.

如果餐点准备好了,服务员将餐点交付给顾客。 但是,如果晚饭或无法做饭,服务生将不得不回头给顾客,道歉,并有可能要求第二道菜。

In our test run, it wouldn’t make sense to actually create the meals when we want to test the front-end’s (waiter’s) ability to fulfill the requests received from the backend (kitchen). More importantly, if we wanted to test our waiters could actually apologize to customers in the cases where a meal is delayed or cannot be made we would literally be waiting until our cooks were too slow or we ran out of ingredients before our tests for those cases could be confirmed. For this reason, we would “mock” the backend (kitchen) and give the waiters whatever scenario it is that we want to test.

在我们的测试运行中,当我们想要测试前端(服务员)满足从后端(厨房)收到的请求的能力时,实际创建餐点没有任何意义。 更重要的是,如果我们想测试我们的服务生可能在用餐延迟或无法做饭的情况下向顾客道歉,我们将等到厨师做得太慢或在测试之前用尽食材。可以确认。 因此,我们将“模拟”后端(厨房),并为服务员提供我们要测试的任何情况。

Similarly in code, we don’t actually hit the API when we’re testing various scenarios. We mock the response we may expect to receive and verify that our application can handle that response accordingly. Just like our kitchen example, if we were testing our application’s ability to handle an API call that failed we would literally have to wait for our API to fail to verify it could handle that case—a scenario that hopefully won’t be happening that often!

同样,在代码中,我们在测试各种场景时实际上并没有使用API​​。 我们模拟可能期望收到的响应,并验证我们的应用程序可以相应地处理该响应。 就像我们的厨房示例一样,如果我们正在测试应用程序处理失败的API调用的能力,那么我们实际上必须等待我们的API未能验证它可以处理这种情况-希望这种情况不会经常发生!

添加用户 ( Adding users )

To get this test to pass, we need to implement the service method in users.service.ts.

为了使此测试通过,我们需要在users.service.ts实现service方法。

First, we'll start by adding our imports and a collection of employees to the service.

首先,我们将在服务中添加我们的进口商品和一批员工。

import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs'; // Add imports@Injectable({providedIn: 'root'
})
export class UsersService {users: Array<object> = [  // Add employee object{id: '1',name: 'Jane',role: 'Designer',pokemon: 'Blastoise'},{id: '2',name: 'Bob',role: 'Developer',pokemon: 'Charizard'},{id: '3',name: 'Jim',role: 'Developer',pokemon: 'Venusaur'},{id: '4',name: 'Adam',role: 'Designer',pokemon: 'Yoshi'}];constructor() { }
}

Then, just below our constructor, we can implement all.

然后,在构造函数下方,我们可以实现all

all(): Observable<Array<object>> {return of(this.users);
}

Run ng test again and you should now have passing tests including the new tests for our service method.

再次运行ng test ,您现在应该已经通过了测试,包括针对我们的服务方法的新测试。

将用户添加到主页 ( Add users to the home page )

Now that our service method is ready to use, we can work towards populating our home page with these users.

现在可以使用我们的服务方法了,我们可以努力向这些用户填充主页。

First, we'll update index.html with Bulma to help us with some styling.

首先,我们将使用Bulma更新index.html ,以帮助我们进行一些样式设置。

<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><title>AngularTesting</title><base href="/"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="icon" type="image/x-icon" href="favicon.ico"><!--Add these--><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css"><script defer src="https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script>
</head>
<body><app-root></app-root>
</body>
</html>

Then within home/home.component.ts we can add a call to our new service.

然后,我们可以在home/home.component.ts中添加对新服务的调用。

import { Component, OnInit } from '@angular/core';
import { UsersService } from '../services/users/users.service';@Component({selector: 'app-home',templateUrl: './home.component.html',styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {users;constructor(private usersService: UsersService) { }ngOnInit() {this.usersService.all().subscribe(res => {this.users = res;});}}

First we import our service and inject it into our component's constructor. Then we add a call to the service method within ngOnInit and set the return value to our component's users property.

首先,我们导入服务并将其注入到组件的构造函数中。 然后,在ngOnInit添加对service方法的ngOnInit ,并将返回值设置为组件的users属性。

To display these users to the view, update the template in home/home.component.html.

要在视图中显示这些用户,请更新home/home.component.html的模板。

<section class="section is-small"><div class="container"><div class="columns"><div class="column" *ngFor="let user of users"><div class="box"><div class="content"><p class="has-text-centered is-size-5">{% raw %}{{user.name}}{% endraw %}</p><ul><li><strong>Role:</strong> {% raw %}{{user.role}}{% endraw %}</li><li><strong>Pokemon:</strong> {% raw %}{{user.pokemon}}{% endraw %}</li></ul></div></div></div></div></div>
</section>

Now when you run ng serve and view the home page, you should see the users displayed within Bulma boxes.

现在,当您运行ng serve并查看主页时,您应该看到在布尔玛框中显示的用户。

查找单个用户 ( Finding a single user )

Now that our users are being populated into our home page, we'll add one more service method for finding a single user that will be used for the user profile pages.

现在,我们的用户已填充到我们的主页中,我们将添加另一种服务方法来查找将用于用户个人资料页面的单个用户。

First we'll add the tests for our new service method.

首先,我们将为新的服务方法添加测试。

describe('all', () => {...
});describe('findOne', () => {it('should return a single user', () => {const userResponse = {id: '2',name: 'Bob',role: 'Developer',pokemon: 'Charizard'};let response;spyOn(usersService, 'findOne').and.returnValue(of(userResponse));usersService.findOne('2').subscribe(res => {response = res;});expect(response).toEqual(userResponse);});
});

Here we add a test for the expectation that findOne will return a single user. We declare a userResponse variable set to a mocked response of our service method, a single object from the collection of users.

在这里,我们添加了一个测试,以期望findOne将返回单个用户。 我们声明一个userResponse变量,该变量设置为我们的服务方法的userResponse响应,这是用户集合中的单个对象。

We then create a spy for usersService.findOne and return our mocked userResponse variable. With our spy set, we call our service method and set its return value to response.

然后,我们为usersService.findOne创建一个间谍,并返回userResponse变量。 设置好间谍之后,我们将调用服务方法并将其返回值设置为response

Finally, we add our assertion that response will be set to the return value of the service call, userResponse.

最后,我们添加断言,即将response设置为服务调用的返回值userResponse

To get this test to pass, we can add the following implementation to users.service.ts.

为了使此测试通过,我们可以将以下实现添加到users.service.ts

all(): Observable<Array<object>> {return of(this.users);
}findOne(id: string): Observable<object> {const user = this.users.find((u: any) => {return u.id === id;});return of(user);
}

Now when you run ng test you should see all of the tests in a passing state.

现在,当您运行ng test您应该看到所有测试都处于通过状态。

结论 ( Conclusion )

At this point I hope testing, both its benefits and the reason for writing them, is starting to become a bit more clear. Personally, I pushed off testing for the longest time and my reasons were primarily because I didn't understand the why behind them and resources for testing were limited.

在这一点上,我希望测试的好处和编写它们的理由,已经变得更加清晰。 就我个人而言,我推迟了最长的测试时间,原因主要是因为我不了解其背后的原因以及测试资源有限。

What we've created in this tutorial isn't the most visually impressive application but it's a step in the right direction.

我们在本教程中创建的内容并不是视觉上最令人印象深刻的应用程序,而是朝着正确方向迈出的一步。

In the next tutorial, we'll create the user profile page and a service to retrieve a Pokemon image using the Pokeapi. We'll learn how to test service methods that make HTTP requests and how to test components.

在下一个教程中,我们将创建用户个人资料页面和使用Pokeapi检索Pokemon图像的服务 。 我们将学习如何测试发出HTTP请求的服务方法以及如何测试组件。

额外 ( Extra )

If you want the tests to display in a more readable format within your terminal, there's an npm package for this.

如果您希望测试在终端中以更易读的格式显示,则有一个npm软件包。

First, install the package.

首先,安装软件包。

npm install karma-spec-reporter --save-dev

Once that's finished, open src/karma.conf.js, add the new package to plugins, and update the progress value within reporters to spec.

完成后,打开src/karma.conf.js ,将新包添加到plugins ,然后将reportersprogress值更新为spec

module.exports = function (config) {config.set({basePath: '',frameworks: ['jasmine', '@angular-devkit/build-angular'],plugins: [require('karma-jasmine'),require('karma-chrome-launcher'),require('karma-jasmine-html-reporter'),require('karma-coverage-istanbul-reporter'),require('@angular-devkit/build-angular/plugins/karma'),require('karma-spec-reporter') // Add this],client: {clearContext: false // leave Jasmine Spec Runner output visible in browser},coverageIstanbulReporter: {dir: require('path').join(__dirname, '../coverage'),reports: ['html', 'lcovonly'],fixWebpackSourcePaths: true},reporters: ['spec', 'kjhtml'], // Update progress to specport: 9876,colors: true,logLevel: config.LOG_INFO,autoWatch: true,browsers: ['Chrome'],singleRun: false});
};

Now when you run ng test you should have a more visually appealing output for your test suite.

现在,当您运行ng test您应该为测试套件提供更具视觉吸引力的输出。

翻译自: https://scotch.io/tutorials/testing-angular-with-jasmine-and-karma-part-1

karma jasmine

查看全文
如若内容造成侵权/违法违规/事实不符,请联系编程学习网邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

相关文章

  1. Angular初学

    今天学习是学习Angular第二天&#xff0c;感觉自己看是慢慢陷入它所设置的迷魂阵&#xff0c;我享受其中&#xff0c;收获良多。 首先记录一下很有用的博客页面&#xff0c;感谢&#xff01; 手把手教你如何安装和使用Karma-Jasmine&#xff1a;http://www.tuicool.com/articl…...

    2024/4/20 19:19:34
  2. (c语言)选择排序法和冒泡排序法

    问题描述: 给定一个数组(或者输入一个数组),分别运用选择排序法和冒泡排序法将所要的结果输出。 程序分析:选择排序 1>.对于选择排序,首先理解排序的思想。给定一个数组,这种思想首先假定数组的首元素为最大(最小)的。此时就要利用3个变量i,j,k表示元素的下标。i…...

    2024/4/20 19:19:35
  3. Angular 构建系统

    Angular 构建系统npm包管理器Angular CLI项目配置文件npm包管理器 Angular框架、Angular CLI、Angular应用程序所用到的组件都打包成npm packages&#xff0c;并通过npm registry进行分发。 npm安装的包都会在package.json中&#xff0c;package.json文件中的包被分为了两组&…...

    2024/4/21 5:41:01
  4. Karma 5:集成 Karma 和 Angular2

    集成 Karma 和 Angular2 我们需要做很多工作&#xff0c;由于需要使用 TypeScript 进行开发&#xff0c;首先需要正确配置 Typescript &#xff0c;然后正确配置对 Angular2 的引用。还要创建 Karma 的入口文件&#xff0c;以便进行打包。 1. 安装工具 安装 Angular2.beta.7 ka…...

    2024/4/21 5:41:00
  5. static全局变量与普通的全局变量的区别?

    1、static全局变量与普通的全局变量有什么区别?static局部变量和普通局部变量有什么区别?static函数与普通函数有什么区别? 答:全局变量(外部变量)的说明之前再冠以static 就构成了静态的全局变量。全局变量本身就是静态存储方式, 静态全局变量当然也是静态存储方式。 …...

    2024/4/21 5:41:00
  6. 达州双眼皮去妃美

    ...

    2024/4/21 5:40:58
  7. 无锡双眼皮哪里做好

    ...

    2024/4/21 5:40:57
  8. 埋线双眼皮有一段断了

    ...

    2024/5/7 18:48:48
  9. 埋线双眼皮痕迹为什么消失

    ...

    2024/4/28 7:09:49
  10. Angular js Radio Button

    症状&#xff1a; 绑定一个list radio button 老是只能绑定一行&#xff0c;纠结了很久 &#xff0c;回家发现 原来是 name 用了同一个 &#xff0c;坑啊&#xff0c;记录下 免得下次再犯。 之前的代码 <ul><li ng-repeat"row in list"><span>…...

    2024/4/21 5:40:54
  11. angular学习之服务(本地存储)以及获取子组件的值

    在angular中实现服务&#xff0c;用本地存储&#xff0c;刷新以后数据还在 步骤一、命令行输入------表示在app文件夹下新建一个services文件夹&#xff0c;里面放服务(storage&#xff09; ng g service services/storage 步骤二、在根组件的modules.ts引入服务 可以直接复…...

    2024/4/21 5:40:53
  12. angular父组件中获取多个相同子组件

    场景&#xff1a;父组件中 用ngfor循环获取多个相同的子组件&#xff0c;在父组件中调用子组件事件。用户点击按钮整体调用所有的子组件的方法 使用模版变量 在ts中引入子组件&#xff1a; ViewChildren(‘searchDropDown’) searchDropDown: QueryList; 注意&#xff1a;和…...

    2024/4/26 9:00:11
  13. 美容做双眼皮价格合理

    ...

    2024/4/21 5:40:52
  14. angular问题获取不到双向绑定对象ng-modal的值

    在一次项目中&#xff0c;我修改input的值时&#xff0c;获取ng-modal绑定name的值发现居然获取不到值&#xff0c;我以为是变量名的问题&#xff0c;就改了下发现还是没有&#xff0c;突然我发现data.name之类的变量却可以获取到值&#xff0c;真是莫名其妙。 但我还是没有放…...

    2024/4/21 5:40:50
  15. 双眼皮全切法

    ...

    2024/4/21 5:40:49
  16. 双眼皮一个月不消肿

    ...

    2024/4/22 14:44:30
  17. 中国哪里双眼皮做得好啊

    ...

    2024/5/7 13:33:12
  18. 双眼皮内外眼角

    ...

    2024/4/21 5:40:47
  19. angualr5 跨域请求

    最近开发新项目碰到了跨域请求问题&#xff0c;解决办法采用前端代理&#xff1b; 1.首先需要建立一个JSON文件,文件名”proxy.config.json”在angular目录下 {"/v1.1":{"target":http://192.168.123.12, //需要连接机器的ip地址"secure": &qu…...

    2024/4/20 15:00:19
  20. 关于 Angular seesion 跨域 返回null 的问题

    问题&#xff1a;在 angular httpClient 向服务器 发送 get请求时 返回这类情况时 解决:需要在 服务器端 进行 header 定义 Origin 和 Credentials 第一步: 跨域的允许主要由服务器端控制。服务器端通过在响应的 header 中设置 Access-Control-Allow-Origin 及相关一系列参数&a…...

    2024/4/20 19:19:43

最新文章

  1. 多行字符串水平相加

    题目来源与2023河南省ccpc statements_2.pdf (codeforces.com) ls [ ........ ........ .0000000 .0.....0 .0.....0 .0.....0 .0.....0 .0.....0 .0000000 ........ , ........ ........ .......1 .......1 .......1 .......1 .......1 .......1 .......1 ........, ......…...

    2024/5/7 19:09:19
  2. 梯度消失和梯度爆炸的一些处理方法

    在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言&#xff0c;在此感激不尽。 权重和梯度的更新公式如下&#xff1a; w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...

    2024/5/7 10:36:02
  3. MyBatis实战:如何将拼接的SQL打印到日志

    哈喽&#xff0c;大家好&#xff0c;我是木头左&#xff01; 一、前言 在日常开发中&#xff0c;经常会遇到拼接SQL的情况&#xff0c;这时候&#xff0c;如何将拼接的SQL打印到日志&#xff0c;以便追踪和调试呢&#xff1f;本文将详细介绍MyBatis如何实现这一功能。 二、My…...

    2024/5/7 15:40:15
  4. 数据结构--KMP算法

    数据结构–KMP算法 首先我在这里提出以下问题&#xff0c;一会一起进行探讨 1.什么是最长公共前后缀 2. KMP算法怎么实现对匹配原理 3. 最长公共前后缀怎么求解 KMP算法可以用来解决什么问题&#xff1f; 答&#xff1a;在字符串中匹配子串&#xff0c;也称为模式匹配 分析…...

    2024/5/5 0:48:22
  5. 【干货】零售商的商品规划策略

    商品规划&#xff0c;无疑是零售业的生命之源&#xff0c;是推动业务腾飞的强大引擎。一个精心策划的商品规划策略&#xff0c;不仅能帮助零售商在激烈的市场竞争中稳固立足&#xff0c;更能精准捕捉客户需求&#xff0c;实现利润最大化。以下&#xff0c;我们将深入探讨零售商…...

    2024/5/5 12:33:12
  6. 【外汇早评】美通胀数据走低,美元调整

    原标题:【外汇早评】美通胀数据走低,美元调整昨日美国方面公布了新一期的核心PCE物价指数数据,同比增长1.6%,低于前值和预期值的1.7%,距离美联储的通胀目标2%继续走低,通胀压力较低,且此前美国一季度GDP初值中的消费部分下滑明显,因此市场对美联储后续更可能降息的政策…...

    2024/5/7 5:50:09
  7. 【原油贵金属周评】原油多头拥挤,价格调整

    原标题:【原油贵金属周评】原油多头拥挤,价格调整本周国际劳动节,我们喜迎四天假期,但是整个金融市场确实流动性充沛,大事频发,各个商品波动剧烈。美国方面,在本周四凌晨公布5月份的利率决议和新闻发布会,维持联邦基金利率在2.25%-2.50%不变,符合市场预期。同时美联储…...

    2024/5/7 9:45:25
  8. 【外汇周评】靓丽非农不及疲软通胀影响

    原标题:【外汇周评】靓丽非农不及疲软通胀影响在刚结束的周五,美国方面公布了新一期的非农就业数据,大幅好于前值和预期,新增就业重新回到20万以上。具体数据: 美国4月非农就业人口变动 26.3万人,预期 19万人,前值 19.6万人。 美国4月失业率 3.6%,预期 3.8%,前值 3…...

    2024/5/4 23:54:56
  9. 【原油贵金属早评】库存继续增加,油价收跌

    原标题:【原油贵金属早评】库存继续增加,油价收跌周三清晨公布美国当周API原油库存数据,上周原油库存增加281万桶至4.692亿桶,增幅超过预期的74.4万桶。且有消息人士称,沙特阿美据悉将于6月向亚洲炼油厂额外出售更多原油,印度炼油商预计将每日获得至多20万桶的额外原油供…...

    2024/5/7 14:25:14
  10. 【外汇早评】日本央行会议纪要不改日元强势

    原标题:【外汇早评】日本央行会议纪要不改日元强势近两日日元大幅走强与近期市场风险情绪上升,避险资金回流日元有关,也与前一段时间的美日贸易谈判给日本缓冲期,日本方面对汇率问题也避免继续贬值有关。虽然今日早间日本央行公布的利率会议纪要仍然是支持宽松政策,但这符…...

    2024/5/4 23:54:56
  11. 【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响

    原标题:【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响近日伊朗局势升温,导致市场担忧影响原油供给,油价试图反弹。此时OPEC表态稳定市场。据消息人士透露,沙特6月石油出口料将低于700万桶/日,沙特已经收到石油消费国提出的6月份扩大出口的“适度要求”,沙特将满…...

    2024/5/4 23:55:05
  12. 【外汇早评】美欲与伊朗重谈协议

    原标题:【外汇早评】美欲与伊朗重谈协议美国对伊朗的制裁遭到伊朗的抗议,昨日伊朗方面提出将部分退出伊核协议。而此行为又遭到欧洲方面对伊朗的谴责和警告,伊朗外长昨日回应称,欧洲国家履行它们的义务,伊核协议就能保证存续。据传闻伊朗的导弹已经对准了以色列和美国的航…...

    2024/5/4 23:54:56
  13. 【原油贵金属早评】波动率飙升,市场情绪动荡

    原标题:【原油贵金属早评】波动率飙升,市场情绪动荡因中美贸易谈判不安情绪影响,金融市场各资产品种出现明显的波动。随着美国与中方开启第十一轮谈判之际,美国按照既定计划向中国2000亿商品征收25%的关税,市场情绪有所平复,已经开始接受这一事实。虽然波动率-恐慌指数VI…...

    2024/5/7 11:36:39
  14. 【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试

    原标题:【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试美国和伊朗的局势继续升温,市场风险情绪上升,避险黄金有向上突破阻力的迹象。原油方面稍显平稳,近期美国和OPEC加大供给及市场需求回落的影响,伊朗局势并未推升油价走强。近期中美贸易谈判摩擦再度升级,美国对中…...

    2024/5/4 23:54:56
  15. 【原油贵金属早评】市场情绪继续恶化,黄金上破

    原标题:【原油贵金属早评】市场情绪继续恶化,黄金上破周初中国针对于美国加征关税的进行的反制措施引发市场情绪的大幅波动,人民币汇率出现大幅的贬值动能,金融市场受到非常明显的冲击。尤其是波动率起来之后,对于股市的表现尤其不安。隔夜美国股市出现明显的下行走势,这…...

    2024/5/6 1:40:42
  16. 【外汇早评】美伊僵持,风险情绪继续升温

    原标题:【外汇早评】美伊僵持,风险情绪继续升温昨日沙特两艘油轮再次发生爆炸事件,导致波斯湾局势进一步恶化,市场担忧美伊可能会出现摩擦生火,避险品种获得支撑,黄金和日元大幅走强。美指受中美贸易问题影响而在低位震荡。继5月12日,四艘商船在阿联酋领海附近的阿曼湾、…...

    2024/5/4 23:54:56
  17. 【原油贵金属早评】贸易冲突导致需求低迷,油价弱势

    原标题:【原油贵金属早评】贸易冲突导致需求低迷,油价弱势近日虽然伊朗局势升温,中东地区几起油船被袭击事件影响,但油价并未走高,而是出于调整结构中。由于市场预期局势失控的可能性较低,而中美贸易问题导致的全球经济衰退风险更大,需求会持续低迷,因此油价调整压力较…...

    2024/5/4 23:55:17
  18. 氧生福地 玩美北湖(上)——为时光守候两千年

    原标题:氧生福地 玩美北湖(上)——为时光守候两千年一次说走就走的旅行,只有一张高铁票的距离~ 所以,湖南郴州,我来了~ 从广州南站出发,一个半小时就到达郴州西站了。在动车上,同时改票的南风兄和我居然被分到了一个车厢,所以一路非常愉快地聊了过来。 挺好,最起…...

    2024/5/7 9:26:26
  19. 氧生福地 玩美北湖(中)——永春梯田里的美与鲜

    原标题:氧生福地 玩美北湖(中)——永春梯田里的美与鲜一觉醒来,因为大家太爱“美”照,在柳毅山庄去寻找龙女而错过了早餐时间。近十点,向导坏坏还是带着饥肠辘辘的我们去吃郴州最富有盛名的“鱼头粉”。说这是“十二分推荐”,到郴州必吃的美食之一。 哇塞!那个味美香甜…...

    2024/5/4 23:54:56
  20. 氧生福地 玩美北湖(下)——奔跑吧骚年!

    原标题:氧生福地 玩美北湖(下)——奔跑吧骚年!让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 啊……啊……啊 两…...

    2024/5/4 23:55:06
  21. 扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!

    原标题:扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!扒开伪装医用面膜,翻六倍价格宰客!当行业里的某一品项火爆了,就会有很多商家蹭热度,装逼忽悠,最近火爆朋友圈的医用面膜,被沾上了污点,到底怎么回事呢? “比普通面膜安全、效果好!痘痘、痘印、敏感肌都能用…...

    2024/5/5 8:13:33
  22. 「发现」铁皮石斛仙草之神奇功效用于医用面膜

    原标题:「发现」铁皮石斛仙草之神奇功效用于医用面膜丽彦妆铁皮石斛医用面膜|石斛多糖无菌修护补水贴19大优势: 1、铁皮石斛:自唐宋以来,一直被列为皇室贡品,铁皮石斛生于海拔1600米的悬崖峭壁之上,繁殖力差,产量极低,所以古代仅供皇室、贵族享用 2、铁皮石斛自古民间…...

    2024/5/4 23:55:16
  23. 丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者

    原标题:丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者【公司简介】 广州华彬企业隶属香港华彬集团有限公司,专注美业21年,其旗下品牌: 「圣茵美」私密荷尔蒙抗衰,产后修复 「圣仪轩」私密荷尔蒙抗衰,产后修复 「花茵莳」私密荷尔蒙抗衰,产后修复 「丽彦妆」专注医学护…...

    2024/5/4 23:54:58
  24. 广州械字号面膜生产厂家OEM/ODM4项须知!

    原标题:广州械字号面膜生产厂家OEM/ODM4项须知!广州械字号面膜生产厂家OEM/ODM流程及注意事项解读: 械字号医用面膜,其实在我国并没有严格的定义,通常我们说的医美面膜指的应该是一种「医用敷料」,也就是说,医用面膜其实算作「医疗器械」的一种,又称「医用冷敷贴」。 …...

    2024/5/6 21:42:42
  25. 械字号医用眼膜缓解用眼过度到底有无作用?

    原标题:械字号医用眼膜缓解用眼过度到底有无作用?医用眼膜/械字号眼膜/医用冷敷眼贴 凝胶层为亲水高分子材料,含70%以上的水分。体表皮肤温度传导到本产品的凝胶层,热量被凝胶内水分子吸收,通过水分的蒸发带走大量的热量,可迅速地降低体表皮肤局部温度,减轻局部皮肤的灼…...

    2024/5/4 23:54:56
  26. 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...

    解析如下&#xff1a;1、长按电脑电源键直至关机&#xff0c;然后再按一次电源健重启电脑&#xff0c;按F8健进入安全模式2、安全模式下进入Windows系统桌面后&#xff0c;按住“winR”打开运行窗口&#xff0c;输入“services.msc”打开服务设置3、在服务界面&#xff0c;选中…...

    2022/11/19 21:17:18
  27. 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。

    %读入6幅图像&#xff08;每一幅图像的大小是564*564&#xff09; f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...

    2022/11/19 21:17:16
  28. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...

    win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面&#xff0c;在等待界面中我们需要等待操作结束才能关机&#xff0c;虽然这比较麻烦&#xff0c;但是对系统进行配置和升级…...

    2022/11/19 21:17:15
  29. 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...

    有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows&#xff0c;请勿关闭计算机”的提示&#xff0c;要过很久才能进入系统&#xff0c;有的用户甚至几个小时也无法进入&#xff0c;下面就教大家这个问题的解决方法。第一种方法&#xff1a;我们首先在左下角的“开始…...

    2022/11/19 21:17:14
  30. win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...

    置信有很多用户都跟小编一样遇到过这样的问题&#xff0c;电脑时发现开机屏幕显现“正在配置Windows Update&#xff0c;请勿关机”(如下图所示)&#xff0c;而且还需求等大约5分钟才干进入系统。这是怎样回事呢&#xff1f;一切都是正常操作的&#xff0c;为什么开时机呈现“正…...

    2022/11/19 21:17:13
  31. 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...

    Win7系统开机启动时总是出现“配置Windows请勿关机”的提示&#xff0c;没过几秒后电脑自动重启&#xff0c;每次开机都这样无法进入系统&#xff0c;此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一&#xff1a;开机按下F8&#xff0c;在出现的Windows高级启动选…...

    2022/11/19 21:17:12
  32. 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...

    有不少windows10系统用户反映说碰到这样一个情况&#xff0c;就是电脑提示正在准备windows请勿关闭计算机&#xff0c;碰到这样的问题该怎么解决呢&#xff0c;现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法&#xff1a;1、2、依次…...

    2022/11/19 21:17:11
  33. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...

    今天和大家分享一下win7系统重装了Win7旗舰版系统后&#xff0c;每次关机的时候桌面上都会显示一个“配置Windows Update的界面&#xff0c;提示请勿关闭计算机”&#xff0c;每次停留好几分钟才能正常关机&#xff0c;导致什么情况引起的呢&#xff1f;出现配置Windows Update…...

    2022/11/19 21:17:10
  34. 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...

    只能是等着&#xff0c;别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚&#xff0c;只能是考虑备份数据后重装系统了。解决来方案一&#xff1a;管理员运行cmd&#xff1a;net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...

    2022/11/19 21:17:09
  35. 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?

    原标题&#xff1a;电脑提示“配置Windows Update请勿关闭计算机”怎么办&#xff1f;win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢&#xff1f;一般的方…...

    2022/11/19 21:17:08
  36. 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...

    关机提示 windows7 正在配置windows 请勿关闭计算机 &#xff0c;然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;关机提示 windows7 正在配…...

    2022/11/19 21:17:05
  37. 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...

    钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...

    2022/11/19 21:17:05
  38. 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...

    前几天班里有位学生电脑(windows 7系统)出问题了&#xff0c;具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面&#xff0c;长时间没反应&#xff0c;无法进入系统。这个问题原来帮其他同学也解决过&#xff0c;网上搜了不少资料&#x…...

    2022/11/19 21:17:04
  39. 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...

    本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法&#xff0c;并在最后教给你1种保护系统安全的好方法&#xff0c;一起来看看&#xff01;电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中&#xff0c;添加了1个新功能在“磁…...

    2022/11/19 21:17:03
  40. 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...

    许多用户在长期不使用电脑的时候&#xff0c;开启电脑发现电脑显示&#xff1a;配置windows更新失败&#xff0c;正在还原更改&#xff0c;请勿关闭计算机。。.这要怎么办呢&#xff1f;下面小编就带着大家一起看看吧&#xff01;如果能够正常进入系统&#xff0c;建议您暂时移…...

    2022/11/19 21:17:02
  41. 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...

    配置windows update失败 还原更改 请勿关闭计算机&#xff0c;电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;配置windows update失败 还原更改 请勿关闭计算机&#x…...

    2022/11/19 21:17:01
  42. 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...

    不知道大家有没有遇到过这样的一个问题&#xff0c;就是我们的win7系统在关机的时候&#xff0c;总是喜欢显示“准备配置windows&#xff0c;请勿关机”这样的一个页面&#xff0c;没有什么大碍&#xff0c;但是如果一直等着的话就要两个小时甚至更久都关不了机&#xff0c;非常…...

    2022/11/19 21:17:00
  43. 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...

    当电脑出现正在准备配置windows请勿关闭计算机时&#xff0c;一般是您正对windows进行升级&#xff0c;但是这个要是长时间没有反应&#xff0c;我们不能再傻等下去了。可能是电脑出了别的问题了&#xff0c;来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...

    2022/11/19 21:16:59
  44. 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...

    我们使用电脑的过程中有时会遇到这种情况&#xff0c;当我们打开电脑之后&#xff0c;发现一直停留在一个界面&#xff1a;“配置Windows Update失败&#xff0c;还原更改请勿关闭计算机”&#xff0c;等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢&#xff0…...

    2022/11/19 21:16:58
  45. 如何在iPhone上关闭“请勿打扰”

    Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...

    2022/11/19 21:16:57