{"id":321734,"date":"2021-04-19T21:00:37","date_gmt":"2021-04-19T21:00:37","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=321734"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=321734","title":{"rendered":"\u041f\u0438\u0448\u0435\u043c \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u044b \u043d\u0430 TypeScript&#8217;\u0435 (\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043a\u043e\u0442\u0438\u043a\u043e\u0432)"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/64d\/e02\/d9e\/64de02d9e21c1038766d2227d4a063c5.png\" width=\"1120\" height=\"710\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0441 TypeScript&#8217;\u043e\u043c? \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0440\u0435\u0434\u0443 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 TypeScript.<\/p>\n<h2>\u042e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u044b, \u0447\u0442\u043e \u044d\u0442\u043e?<\/h2>\n<p>Unit tests ( \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b) &#8212; \u0442\u0435\u0441\u0442\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u043b\u043e\u044f\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0443\u044e \u0434\u0435\u043b\u0438\u043c\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0434\u0443\u043b\u044c, \u043a\u043b\u0430\u0441\u0441 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<p>\u0421\u0443\u0442\u044c \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u043e\u0432, \u0432 \u0442\u043e\u043c \u0447\u0442\u043e\u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0445 \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043d\u043e\u0432\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u0443, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044f, \u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u043b\u043e \u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u043a \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044e \u043e\u0448\u0438\u0431\u043e\u043a (\u0431\u0430\u0433\u043e\u0432) \u0432 \u0443\u0436\u0435 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<p>\u041e\u0442\u0441\u044e\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0447\u0442\u043e \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u043c\u0438. \u0422\u0430\u043a\u0438\u0435 \u0442\u0435\u0441\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0422.\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u0430, \u043f\u0438\u0448\u0435\u0442 \u043f\u0430\u043a\u0435\u0442 \u0442\u0435\u0441\u0442\u043e\u0432 \u043a \u043d\u0438\u043c, \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0438\u0445 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u043c\u0441\u044f \u0442\u0435\u0441\u0442\u0430\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u043e\u0434 \u043f\u043e\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u0431\u0430\u0433\u043e\u0432 \u0443\u0436\u0435 \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. <\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0418\u0442\u0430\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u0431\u043b\u0438\u0436\u0435 \u043a \u0434\u0435\u043b\u0443. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439:<\/p>\n<pre><code>project | node_modules | src | package.json | tsconfig.json<\/code><\/pre>\n<p> \u0412 <code>.\/src<\/code>  \u043b\u0435\u0436\u0438\u0442 \u043d\u0435\u043a\u0438\u0439 \u043c\u043e\u0434\u0443\u043b\u044c <code>cat.module.ts<\/code> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 Cat.<\/p>\n<pre><code class=\"javascript\">export class Cat {   public name: string;   public color: string;    constructor(name: string, color: string) {     this.name = name;     this.color = color;   }    public move(distanceMeter: number) : string {     return `${this.name} moved ${distanceMeter}m.`;   }    public say() : string {     return `Cat ${this.name} says meow`;   } }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u0438 \u0438 \u0446\u0432\u0435\u0442\u0430 \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0430\u0440\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u042d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u0438 \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u0441\u044f \u043d\u0430\u0448\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (SUT &#8212; system under test).<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043f\u0430\u043f\u043a\u0443 test, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u0442\u0435\u0441\u0442\u044b.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 npm \u043f\u0430\u043a\u0435\u0442\u044b:<\/p>\n<p><code>npm install --save-dev ts-node mocha @testdeck\/mocha nyc chai @types\/chai<\/code><\/p>\n<p>\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u043e\u0432:<br \/><code>ts-node <\/code>&#8212; \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f TypeScript \u0438 REPL \u0432 \u0441\u0440\u0435\u0434\u0435 node.js.<\/p>\n<p><code>mocha <\/code>&#8212; \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439, \u0433\u0438\u0431\u043a\u0438\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u043b\u044e\u0431\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f. \u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u043e\u0441\u043d\u043e\u0432\u0443 \u043d\u0430\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u0412\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>@testdeck\/mocha<\/code> &#8212; \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 testdeck \u0434\u043b\u044f \u041c\u043e\u043a\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0442\u0435\u0441\u0442\u044b \u0432 \u041e\u041e\u041f \u0441\u0442\u0438\u043b\u0435.<\/p>\n<p><code>nyc <\/code>&#8212; \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 CLI \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u044b Istanbul, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0435 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u043a\u043e\u0434\u0430.<\/p>\n<p><code>chai<\/code> &#8212; \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0439(assertions), \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432. \u041c\u044b \u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u0430\u0440\u0435 \u0441 \u041c\u043e\u043a\u043a\u043e\u0439. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0430\u043a \u0436\u0435 <code>@types\/chai <\/code>\u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448 \u0447\u0430\u0438 \u043c\u043e\u0433 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0438\u043f\u0430\u043c\u0438 typescript&#8217;\u0430<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0432\u0441\u0435\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043d\u0430\u0448\u0435\u0439 \u043f\u0430\u043f\u043a\u0435 <code>test<\/code>, \u0444\u0430\u0439\u043b <code>tsconfig.json<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0438 TS \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<pre><code class=\"json\">{   \"extends\": \"..\/tsconfig.json\",   \"compilerOptions\": {     \"baseUrl\": \".\/\",     \"module\": \"commonjs\",     \"experimentalDecorators\": true,     \"strictPropertyInitialization\": false,     \"isolatedModules\": false,     \"strict\": false,     \"noImplicitAny\": false,     \"typeRoots\" : [       \"..\/node_modules\/@types\"     ]   },   \"exclude\": [     \"..\/node_modules\"   ],   \"include\": [     \".\/**\/*.ts\"   ] }<\/code><\/pre>\n<p>\u0412 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 include \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u043f\u0430\u043f\u043a\u0435 test \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u0448\u0438\u0435\u043c .ts<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0444\u0430\u0439\u043b <code>register.js<\/code> \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043f\u0438\u0448\u0435\u043c \u0438\u0441\u043d\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0434\u043b\u044f ts-node, \u043e\u0442\u043a\u0443\u0434\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438 \u0442\u0440\u0430\u043d\u0441\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0442\u0435\u0441\u0442\u044b.<\/p>\n<pre><code class=\"javascript\">const tsNode = require('ts-node'); const testTSConfig = require('.\/test\/tsconfig.json');  tsNode.register({   files: true,   transpileOnly: true,   project: '.\/test\/tsconfig.json' });<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u043c \u0432 \u043a\u043e\u0440\u043d\u0435, \u0444\u0430\u0439\u043b <code>.mocharc.json<\/code>, \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre><code class=\"json\">{   \"require\": \".\/register.js\",   \"reporter\": \"list\" }<\/code><\/pre>\n<p>\u0418 \u0444\u0430\u0439\u043b <code>.nyrc.json<\/code> \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u043c \u043d\u0430\u0448\u0435\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u044f.<\/p>\n<pre><code class=\"json\">{   \"extends\": \"@istanbuljs\/nyc-config-typescript\",   \"include\": [     \"src\/**\/*.ts\"   ],   \"exclude\": [     \"node_modules\/\"   ],   \"extension\": [     \".ts\"   ],   \"reporter\": [     \"text-summary\",     \"html\"   ],   \"report-dir\": \".\/coverage\" }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432, \u0434\u0435\u0440\u0435\u0432\u043e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>project | node_modules | src | test | --- tsconfig.json | .mocharc.json | .nyrc.json | package.json | register.js | tsconfig.json<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432 <code>package.json<\/code><\/p>\n<pre><code class=\"json\">\"test\": \"nyc .\/node_modules\/.bin\/_mocha 'test\/**\/*.test.ts'\"<\/code><\/pre>\n<p>\u0421 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0441\u0442<\/p>\n<h2>\u041f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u044b<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0432 \u043f\u0430\u043f\u043a\u0435 <code>.\/test <\/code>\u0444\u0430\u0439\u043b <code>cat.unit.test.ts<\/code> \u0438 \u043f\u0438\u0448\u0435\u043c \u0432 \u043d\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"javascript\">import { Cat } from '..\/src\/cat.module'; import { suite, test } from '@testdeck\/mocha'; import * as _chai from 'chai'; import { expect } from 'chai';  _chai.should(); _chai.expect;  @suite class CatModuleTest {   private SUT: Cat;   private name: string;   private color: string;    before() {     this.name = 'Tom';     this.color = 'black';     this.SUT = new Cat(this.name, this.color);   } }<\/code><\/pre>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 Cat \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f <code>cat.module.ts<\/code>, \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0447\u0442\u043e\u0431\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<p>\u0412 \u0441\u0435\u043a\u0446\u0438\u0438 before \u0437\u0430\u0434\u0430\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441 \u0438 \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 Cat, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0442\u0435\u0441\u0442\u044b.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0441\u0442, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0449\u0438\u0439 \u0447\u0442\u043e \u043d\u0430\u0448 \u043a\u043e\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 \u0438\u043c\u0435\u0435\u0442 \u0438\u043c\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0435\u043c\u0443 \u0437\u0430\u0434\u0430\u043b\u0438.<\/p>\n<pre><code class=\"javascript\">import { Cat } from '..\/src\/cat.module'; import { suite, test } from '@testdeck\/mocha'; import * as _chai from 'chai'; import { expect } from 'chai';  _chai.should(); _chai.expect;  @suite class CatModuleTest {   private SUT: Cat;   private name: string;   private color: string;    before() {     this.name = 'Tom';     this.color = 'black';     this.SUT = new Cat(this.name, this.color);   }    @test 'Cat is created' () {     this.SUT.name.should.to.not.be.undefined.and.have.property('name').equal('Tom');   } }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u0435\u0441\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 npm test \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/faf\/7e0\/e86\/faf7e0e8634b2a1a644ded752efda995.png\" width=\"652\" height=\"282\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0435 \u0443 \u043d\u0430\u0441 \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0435, \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u043d\u0435 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 11-15. \u042d\u0442\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 Cat <code>move<\/code> \u0438 <code>say.<\/code> <\/p>\n<p>\u0414\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0435\u0449\u0435 \u0434\u0432\u0430 \u0442\u0435\u0441\u0442\u0430 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432 \u0438\u0442\u043e\u0433\u0435 \u0442\u0430\u043a\u043e\u0439 \u0444\u0430\u0439\u043b \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438:<\/p>\n<pre><code class=\"javascript\">import { Cat } from '..\/src\/cat.module'; import { suite, test } from '@testdeck\/mocha'; import * as _chai from 'chai'; import { expect } from 'chai';  _chai.should(); _chai.expect;  @suite class CatModuleTest {   private SUT: Cat;   private name: string;   private color: string;    before() {     this.name = 'Tom';     this.color = 'black';     this.SUT = new Cat(this.name, this.color);   }    @test 'Cat is created' () {     this.SUT.name.should.to.not.be.undefined.and.have.property('name').equal('Tom');   }    @test 'Cat move 10m' () {     let catMove = this.SUT.move(10);     expect(catMove).to.be.equal('Tom moved 10m.');   }    @test 'Cat say meow' () {     expect(this.SUT.say()).to.be.equal('Cat Tom says meow');   } }<\/code><\/pre>\n<p>\u0421\u043d\u043e\u0432\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448\u0438 \u0442\u0435\u0441\u0442\u044b \u0438 \u0432\u0438\u0434\u0438\u043c \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043b\u0430\u0441\u0441 Cat \u0438\u043c\u0435\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d22\/829\/222\/d22829222c9daaacd499f81cd3425c7c.png\" alt=\"\" title=\"\" width=\"649\" height=\"306\"><figcaption><\/figcaption><\/figure>\n<h2>\u0418\u0442\u043e\u0433<\/h2>\n<p>\u041f\u043e \u0438\u0442\u043e\u0433\u0443 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u043b\u044e\u0431\u043e\u0439 \u043d\u043e\u0432\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044f \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0441\u043b\u043e\u043c\u0430\u043b\u0441\u044f.<\/p>\n<p>PS: \u041d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043f\u043e \u043c\u043e\u0442\u0438\u0432\u0430\u043c \u0441\u0442\u0430\u0442\u044c\u0438<a href=\"https:\/\/medium.com\/swlh\/how-to-setting-up-unit-tests-with-typescript-871c0f4f1609\" rel=\"noopener noreferrer nofollow\"> How setting up unit test with TypeScript<\/a>.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/553234\/\"> https:\/\/habr.com\/ru\/post\/553234\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0441 TypeScript&#8217;\u043e\u043c? \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0440\u0435\u0434\u0443 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 TypeScript.<\/p>\n<h2>\u042e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u044b, \u0447\u0442\u043e \u044d\u0442\u043e?<\/h2>\n<p>Unit tests ( \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b) &#8212; \u0442\u0435\u0441\u0442\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u043b\u043e\u044f\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0443\u044e \u0434\u0435\u043b\u0438\u043c\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0434\u0443\u043b\u044c, \u043a\u043b\u0430\u0441\u0441 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<p>\u0421\u0443\u0442\u044c \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u043e\u0432, \u0432 \u0442\u043e\u043c \u0447\u0442\u043e\u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0445 \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043d\u043e\u0432\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u0443, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044f, \u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u043b\u043e \u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u043a \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044e \u043e\u0448\u0438\u0431\u043e\u043a (\u0431\u0430\u0433\u043e\u0432) \u0432 \u0443\u0436\u0435 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<p>\u041e\u0442\u0441\u044e\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0447\u0442\u043e \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u043c\u0438. \u0422\u0430\u043a\u0438\u0435 \u0442\u0435\u0441\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0422.\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u0430, \u043f\u0438\u0448\u0435\u0442 \u043f\u0430\u043a\u0435\u0442 \u0442\u0435\u0441\u0442\u043e\u0432 \u043a \u043d\u0438\u043c, \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0438\u0445 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u043c\u0441\u044f \u0442\u0435\u0441\u0442\u0430\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u043e\u0434 \u043f\u043e\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u0431\u0430\u0433\u043e\u0432 \u0443\u0436\u0435 \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. <\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0418\u0442\u0430\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u0431\u043b\u0438\u0436\u0435 \u043a \u0434\u0435\u043b\u0443. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439:<\/p>\n<pre><code>project | node_modules | src | package.json | tsconfig.json<\/code><\/pre>\n<p> \u0412 <code>.\/src<\/code>  \u043b\u0435\u0436\u0438\u0442 \u043d\u0435\u043a\u0438\u0439 \u043c\u043e\u0434\u0443\u043b\u044c <code>cat.module.ts<\/code> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 Cat.<\/p>\n<pre><code class=\"javascript\">export class Cat {   public name: string;   public color: string;    constructor(name: string, color: string) {     this.name = name;     this.color = color;   }    public move(distanceMeter: number) : string {     return `${this.name} moved ${distanceMeter}m.`;   }    public say() : string {     return `Cat ${this.name} says meow`;   } }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u0438 \u0438 \u0446\u0432\u0435\u0442\u0430 \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0430\u0440\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u042d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u0438 \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u0441\u044f \u043d\u0430\u0448\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (SUT &#8212; system under test).<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043f\u0430\u043f\u043a\u0443 test, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u0442\u0435\u0441\u0442\u044b.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 npm \u043f\u0430\u043a\u0435\u0442\u044b:<\/p>\n<p><code>npm install --save-dev ts-node mocha @testdeck\/mocha nyc chai @types\/chai<\/code><\/p>\n<p>\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u043e\u0432:<br \/><code>ts-node <\/code>&#8212; \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f TypeScript \u0438 REPL \u0432 \u0441\u0440\u0435\u0434\u0435 node.js.<\/p>\n<p><code>mocha <\/code>&#8212; \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439, \u0433\u0438\u0431\u043a\u0438\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u043b\u044e\u0431\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f. \u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u043e\u0441\u043d\u043e\u0432\u0443 \u043d\u0430\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u0412\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>@testdeck\/mocha<\/code> &#8212; \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 testdeck \u0434\u043b\u044f \u041c\u043e\u043a\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0442\u0435\u0441\u0442\u044b \u0432 \u041e\u041e\u041f \u0441\u0442\u0438\u043b\u0435.<\/p>\n<p><code>nyc <\/code>&#8212; \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 CLI \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u044b Istanbul, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0435 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u043a\u043e\u0434\u0430.<\/p>\n<p><code>chai<\/code> &#8212; \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0439(assertions), \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432. \u041c\u044b \u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u0430\u0440\u0435 \u0441 \u041c\u043e\u043a\u043a\u043e\u0439. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0430\u043a \u0436\u0435 <code>@types\/chai <\/code>\u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448 \u0447\u0430\u0438 \u043c\u043e\u0433 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0438\u043f\u0430\u043c\u0438 typescript&#8217;\u0430<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0432\u0441\u0435\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043d\u0430\u0448\u0435\u0439 \u043f\u0430\u043f\u043a\u0435 <code>test<\/code>, \u0444\u0430\u0439\u043b <code>tsconfig.json<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0438 TS \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<pre><code class=\"json\">{   \"extends\": \"..\/tsconfig.json\",   \"compilerOptions\": {     \"baseUrl\": \".\/\",     \"module\": \"commonjs\",     \"experimentalDecorators\": true,     \"strictPropertyInitialization\": false,     \"isolatedModules\": false,     \"strict\": false,     \"noImplicitAny\": false,     \"typeRoots\" : [       \"..\/node_modules\/@types\"     ]   },   \"exclude\": [     \"..\/node_modules\"   ],   \"include\": [     \".\/**\/*.ts\"   ] }<\/code><\/pre>\n<p>\u0412 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 include \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u043f\u0430\u043f\u043a\u0435 test \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u0448\u0438\u0435\u043c .ts<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0444\u0430\u0439\u043b <code>register.js<\/code> \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043f\u0438\u0448\u0435\u043c \u0438\u0441\u043d\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0434\u043b\u044f ts-node, \u043e\u0442\u043a\u0443\u0434\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438 \u0442\u0440\u0430\u043d\u0441\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0442\u0435\u0441\u0442\u044b.<\/p>\n<pre><code class=\"javascript\">const tsNode = require('ts-node'); const testTSConfig = require('.\/test\/tsconfig.json');  tsNode.register({   files: true,   transpileOnly: true,   project: '.\/test\/tsconfig.json' });<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u043c \u0432 \u043a\u043e\u0440\u043d\u0435, \u0444\u0430\u0439\u043b <code>.mocharc.json<\/code>, \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre><code class=\"json\">{   \"require\": \".\/register.js\",   \"reporter\": \"list\" }<\/code><\/pre>\n<p>\u0418 \u0444\u0430\u0439\u043b <code>.nyrc.json<\/code> \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u043c \u043d\u0430\u0448\u0435\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u044f.<\/p>\n<pre><code class=\"json\">{   \"extends\": \"@istanbuljs\/nyc-config-typescript\",   \"include\": [     \"src\/**\/*.ts\"   ],   \"exclude\": [     \"node_modules\/\"   ],   \"extension\": [     \".ts\"   ],   \"reporter\": [     \"text-summary\",     \"html\"   ],   \"report-dir\": \".\/coverage\" }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432, \u0434\u0435\u0440\u0435\u0432\u043e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>project | node_modules | src | test | --- tsconfig.json | .mocharc.json | .nyrc.json | package.json | register.js | tsconfig.json<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432 <code>package.json<\/code><\/p>\n<pre><code class=\"json\">\"test\": \"nyc .\/node_modules\/.bin\/_mocha 'test\/**\/*.test.ts'\"<\/code><\/pre>\n<p>\u0421 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0441\u0442<\/p>\n<h2>\u041f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u044b<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0432 \u043f\u0430\u043f\u043a\u0435 <code>.\/test <\/code>\u0444\u0430\u0439\u043b <code>cat.unit.test.ts<\/code> \u0438 \u043f\u0438\u0448\u0435\u043c \u0432 \u043d\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"javascript\">import { Cat } from '..\/src\/cat.module'; import { suite, test } from '@testdeck\/mocha'; import * as _chai from 'chai'; import { expect } from 'chai';  _chai.should(); _chai.expect;  @suite class CatModuleTest {   private SUT: Cat;   private name: string;   private color: string;    before() {     this.name = 'Tom';     this.color = 'black';     this.SUT = new Cat(this.name, this.color);   } }<\/code><\/pre>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 Cat \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f <code>cat.module.ts<\/code>, \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0447\u0442\u043e\u0431\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<p>\u0412 \u0441\u0435\u043a\u0446\u0438\u0438 before \u0437\u0430\u0434\u0430\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441 \u0438 \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 Cat, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0442\u0435\u0441\u0442\u044b.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0441\u0442, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0449\u0438\u0439 \u0447\u0442\u043e \u043d\u0430\u0448 \u043a\u043e\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 \u0438\u043c\u0435\u0435\u0442 \u0438\u043c\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0435\u043c\u0443 \u0437\u0430\u0434\u0430\u043b\u0438.<\/p>\n<pre><code class=\"javascript\">import { Cat } from '..\/src\/cat.module'; import { suite, test } from '@testdeck\/mocha'; import * as _chai from 'chai'; import { expect } from 'chai';  _chai.should(); _chai.expect;  @suite class CatModuleTest {   private SUT: Cat;   private name: string;   private color: string;    before() {     this.name = 'Tom';     this.color = 'black';     this.SUT = new Cat(this.name, this.color);   }    @test 'Cat is created' () {     this.SUT.name.should.to.not.be.undefined.and.have.property('name').equal('Tom');   } }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u0435\u0441\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 npm test \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0435:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0435 \u0443 \u043d\u0430\u0441 \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0435, \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u043d\u0435 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 11-15. \u042d\u0442\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 Cat <code>move<\/code> \u0438 <code>say.<\/code> <\/p>\n<p>\u0414\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0435\u0449\u0435 \u0434\u0432\u0430 \u0442\u0435\u0441\u0442\u0430 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432 \u0438\u0442\u043e\u0433\u0435 \u0442\u0430\u043a\u043e\u0439 \u0444\u0430\u0439\u043b \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438:<\/p>\n<pre><code class=\"javascript\">import { Cat } from '..\/src\/cat.module'; import { suite, test } from '@testdeck\/mocha'; import * as _chai from 'chai'; import { expect } from 'chai';  _chai.should(); _chai.expect;  @suite class CatModuleTest {   private SUT: Cat;   private name: string;   private color: string;    before() {     this.name = 'Tom';     this.color = 'black';     this.SUT = new Cat(this.name, this.color);   }    @test 'Cat is created' () {     this.SUT.name.should.to.not.be.undefined.and.have.property('name').equal('Tom');   }    @test 'Cat move 10m' () {     let catMove = this.SUT.move(10);     expect(catMove).to.be.equal('Tom moved 10m.');   }    @test 'Cat say meow' () {     expect(this.SUT.say()).to.be.equal('Cat Tom says meow');   } }<\/code><\/pre>\n<p>\u0421\u043d\u043e\u0432\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448\u0438 \u0442\u0435\u0441\u0442\u044b \u0438 \u0432\u0438\u0434\u0438\u043c \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043b\u0430\u0441\u0441 Cat \u0438\u043c\u0435\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0435.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u0418\u0442\u043e\u0433<\/h2>\n<p>\u041f\u043e \u0438\u0442\u043e\u0433\u0443 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u043b\u044e\u0431\u043e\u0439 \u043d\u043e\u0432\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044f \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0441\u043b\u043e\u043c\u0430\u043b\u0441\u044f.<\/p>\n<p>PS: \u041d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043f\u043e \u043c\u043e\u0442\u0438\u0432\u0430\u043c \u0441\u0442\u0430\u0442\u044c\u0438<a href=\"https:\/\/medium.com\/swlh\/how-to-setting-up-unit-tests-with-typescript-871c0f4f1609\" rel=\"noopener noreferrer nofollow\"> How setting up unit test with TypeScript<\/a>.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/553234\/\"> https:\/\/habr.com\/ru\/post\/553234\/<\/a><br \/><\/br><\/br><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-321734","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/321734","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=321734"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/321734\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=321734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=321734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=321734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}