Skip to content
Permalink
Browse files

Chore: Update 'ava' to 'v1.1.0'

Fix #1597
Close #1720
  • Loading branch information...
sarvaje authored and molant committed Jan 23, 2019
1 parent f893257 commit 91b1e213ec18901a23e2eb737f4831ec3ae1d65a
Showing with 2,518 additions and 2,414 deletions.
  1. +1 βˆ’1 packages/connector-chrome/package.json
  2. +38 βˆ’28 packages/connector-chrome/tests/collect.ts
  3. +23 βˆ’12 packages/connector-chrome/tests/evaluate.ts
  4. +32 βˆ’23 packages/connector-chrome/tests/events.ts
  5. +19 βˆ’8 packages/connector-chrome/tests/fetchContent.ts
  6. +18 βˆ’8 packages/connector-chrome/tests/invalid-url.ts
  7. +33 βˆ’24 packages/connector-chrome/tests/requestResponse.ts
  8. +1 βˆ’1 packages/connector-jsdom/package.json
  9. +37 βˆ’27 packages/connector-jsdom/tests/collect.ts
  10. +20 βˆ’8 packages/connector-jsdom/tests/evaluate.ts
  11. +32 βˆ’21 packages/connector-jsdom/tests/events.ts
  12. +19 βˆ’8 packages/connector-jsdom/tests/fetchContent.ts
  13. +25 βˆ’9 packages/connector-jsdom/tests/invalid-url.ts
  14. +33 βˆ’24 packages/connector-jsdom/tests/requestResponse.ts
  15. +1 βˆ’1 packages/connector-local/package.json
  16. +74 βˆ’67 packages/connector-local/tests/tests.ts
  17. +1 βˆ’1 packages/create-hint/package.json
  18. +1 βˆ’1 packages/create-hint/src/shared-templates/package.hbs
  19. +1 βˆ’1 packages/create-hint/tests/handlebars-utils.ts
  20. +1 βˆ’1 packages/create-hintrc/package.json
  21. +7 βˆ’1 packages/create-hintrc/tests/browserslist.ts
  22. +22 βˆ’25 packages/create-hintrc/tests/create-hintrc.ts
  23. +1 βˆ’1 packages/create-parser/package.json
  24. +1 βˆ’1 packages/create-parser/src/shared-templates/package.hbs
  25. +1 βˆ’1 packages/create-parser/tests/handlebars-utils.ts
  26. +42 βˆ’46 packages/create-parser/tests/new-parser.ts
  27. +1 βˆ’1 packages/extension-browser/package.json
  28. +1 βˆ’1 packages/extension-vscode/package.json
  29. +60 βˆ’15 packages/extension-vscode/tests/fixtures/mocks.ts
  30. +60 βˆ’48 packages/extension-vscode/tests/server.ts
  31. +1 βˆ’1 packages/formatter-codeframe/package.json
  32. +13 βˆ’9 packages/formatter-codeframe/tests/tests.ts
  33. +1 βˆ’1 packages/formatter-excel/package.json
  34. +11 βˆ’3 packages/formatter-excel/tests/tests.ts
  35. +1 βˆ’1 packages/formatter-html/package.json
  36. +16 βˆ’20 packages/formatter-html/tests/tests.ts
  37. +1 βˆ’1 packages/formatter-json/package.json
  38. +13 βˆ’9 packages/formatter-json/tests/tests.ts
  39. +1 βˆ’1 packages/formatter-stylish/package.json
  40. +13 βˆ’9 packages/formatter-stylish/tests/tests.ts
  41. +1 βˆ’1 packages/formatter-summary/package.json
  42. +18 βˆ’15 packages/formatter-summary/tests/tests.ts
  43. +1 βˆ’1 packages/hint-amp-validator/package.json
  44. +1 βˆ’1 packages/hint-apple-touch-icons/package.json
  45. +1 βˆ’1 packages/hint-axe/package.json
  46. +1 βˆ’1 packages/hint-axe/tests/tests.ts
  47. +1 βˆ’1 packages/hint-babel-config/package.json
  48. +1 βˆ’1 packages/hint-button-type/package.json
  49. +1 βˆ’1 packages/hint-compat-api/package.json
  50. +1 βˆ’1 packages/hint-compat-api/tests/css.ts
  51. +1 βˆ’1 packages/hint-content-type/package.json
  52. +1 βˆ’1 packages/hint-disown-opener/package.json
  53. +1 βˆ’5 packages/hint-disown-opener/tests/tests.ts
  54. +1 βˆ’1 packages/hint-doctype/package.json
  55. +1 βˆ’1 packages/hint-highest-available-document-mode/package.json
  56. +1 βˆ’1 packages/hint-html-checker/package.json
  57. +2 βˆ’2 packages/hint-html-checker/tests/tests.ts
  58. +1 βˆ’1 packages/hint-http-cache/package.json
  59. +1 βˆ’1 packages/hint-http-compression/package.json
  60. +3 βˆ’3 packages/hint-http-compression/tests/_tests.ts
  61. +1 βˆ’1 packages/hint-https-only/package.json
  62. +2 βˆ’2 packages/hint-https-only/tests/tests-https.ts
  63. +1 βˆ’1 packages/hint-image-optimization-cloudinary/package.json
  64. +1 βˆ’1 packages/hint-manifest-app-name/package.json
  65. +1 βˆ’1 packages/hint-manifest-exists/package.json
  66. +1 βˆ’1 packages/hint-manifest-file-extension/package.json
  67. +1 βˆ’1 packages/hint-manifest-is-valid/package.json
  68. +1 βˆ’1 packages/hint-meta-charset-utf-8/package.json
  69. +1 βˆ’1 packages/hint-meta-theme-color/package.json
  70. +1 βˆ’1 packages/hint-meta-viewport/package.json
  71. +1 βˆ’1 packages/hint-minified-js/package.json
  72. +1 βˆ’1 packages/hint-no-bom/package.json
  73. +1 βˆ’1 packages/hint-no-broken-links/package.json
  74. +1 βˆ’1 packages/hint-no-broken-links/tests/tests.ts
  75. +1 βˆ’1 packages/hint-no-disallowed-headers/package.json
  76. +1 βˆ’1 packages/hint-no-friendly-error-pages/package.json
  77. +1 βˆ’1 packages/hint-no-html-only-headers/package.json
  78. +1 βˆ’1 packages/hint-no-http-redirects/package.json
  79. +1 βˆ’1 packages/hint-no-http-redirects/tests/tests.ts
  80. +1 βˆ’1 packages/hint-no-p3p/package.json
  81. +1 βˆ’1 packages/hint-no-protocol-relative-urls/package.json
  82. +1 βˆ’1 packages/hint-no-vulnerable-javascript-libraries/package.json
  83. +1 βˆ’1 packages/hint-performance-budget/package.json
  84. +2 βˆ’2 packages/hint-performance-budget/tests/tests-http.ts
  85. +2 βˆ’2 packages/hint-performance-budget/tests/tests-https.ts
  86. +1 βˆ’1 packages/hint-sri/package.json
  87. +2 βˆ’2 packages/hint-sri/tests/tests-https.ts
  88. +1 βˆ’1 packages/hint-ssllabs/package.json
  89. +2 βˆ’2 packages/hint-ssllabs/tests/tests.ts
  90. +1 βˆ’1 packages/hint-strict-transport-security/package.json
  91. +2 βˆ’2 packages/hint-strict-transport-security/tests/http-tests.ts
  92. +1 βˆ’1 packages/hint-stylesheet-limits/package.json
  93. +1 βˆ’1 packages/hint-typescript-config/package.json
  94. +15 βˆ’11 packages/hint-typescript-config/tests/import-helpers.ts
  95. +2 βˆ’2 packages/hint-typescript-config/tests/is-valid.ts
  96. +1 βˆ’1 packages/hint-validate-set-cookie-header/package.json
  97. +11 βˆ’11 packages/hint-validate-set-cookie-header/tests/tests.ts
  98. +1 βˆ’1 packages/hint-webpack-config/package.json
  99. +4 βˆ’4 packages/hint-webpack-config/tests/module-esnext-typescript.ts
  100. +4 βˆ’4 packages/hint-webpack-config/tests/modules-false-babel.ts
  101. +1 βˆ’1 packages/hint-x-content-type-options/package.json
  102. +1 βˆ’1 packages/hint/package.json
  103. +9 βˆ’11 packages/hint/tests/lib/cli.ts
  104. +26 βˆ’27 packages/hint/tests/lib/cli/analyze.ts
  105. +24 βˆ’14 packages/hint/tests/lib/cli/help.ts
  106. +22 βˆ’12 packages/hint/tests/lib/cli/version.ts
  107. +21 βˆ’23 packages/hint/tests/lib/config.ts
  108. +12 βˆ’2 packages/hint/tests/lib/engine.ts
  109. +14 βˆ’7 packages/hint/tests/lib/types/parser.ts
  110. +46 βˆ’44 packages/hint/tests/lib/utils/appinsights.ts
  111. +10 βˆ’4 packages/hint/tests/lib/utils/fs/read-file-async.ts
  112. +15 βˆ’12 packages/hint/tests/lib/utils/location-helpers.ts
  113. +24 βˆ’17 packages/hint/tests/lib/utils/logging.ts
  114. +36 βˆ’41 packages/hint/tests/lib/utils/npm.ts
  115. +4 βˆ’2 packages/hint/tests/lib/utils/resource-loader.ts
  116. +1 βˆ’1 packages/hint/tests/lib/utils/schema-validator.ts
  117. +1 βˆ’1 packages/parser-babel-config/package.json
  118. +1 βˆ’1 packages/parser-babel-config/src/types.ts
  119. +110 βˆ’67 packages/parser-babel-config/tests/tests.ts
  120. +1 βˆ’1 packages/parser-css/package.json
  121. +17 βˆ’16 packages/parser-css/tests/basic-tests.ts
  122. +56 βˆ’32 packages/parser-css/tests/interface-tests.ts
  123. +1 βˆ’1 packages/parser-html/package.json
  124. +27 βˆ’23 packages/parser-html/tests/parser.ts
  125. +1 βˆ’1 packages/parser-javascript/package.json
  126. +79 βˆ’56 packages/parser-javascript/tests/tests.ts
  127. +1 βˆ’1 packages/parser-manifest/package.json
  128. +81 βˆ’75 packages/parser-manifest/tests/tests.ts
  129. +1 βˆ’1 packages/parser-package-json/package.json
  130. +48 βˆ’39 packages/parser-package-json/tests/tests.ts
  131. +1 βˆ’1 packages/parser-typescript-config/package.json
  132. +75 βˆ’63 packages/parser-typescript-config/tests/tests.ts
  133. +1 βˆ’1 packages/parser-webpack-config/package.json
  134. +47 βˆ’37 packages/parser-webpack-config/tests/webpack-config.ts
  135. +1 βˆ’1 packages/utils-connector-tools/package.json
  136. +8 βˆ’2 packages/utils-connector-tools/tests/redirects.ts
  137. +28 βˆ’13 packages/utils-connector-tools/tests/requester.ts
  138. +1 βˆ’1 packages/utils-tests-helpers/package.json
  139. +12 βˆ’6 packages/utils-tests-helpers/src/hint-runner.ts
  140. +3 βˆ’3 packages/utils-tests-helpers/src/hint-test-type.ts
  141. +856 βˆ’1,169 yarn.lock
@@ -18,7 +18,7 @@
"@types/is-ci": "^1.1.0",
"@types/lockfile": "^1.0.0",
"@types/lodash": "^4.14.120",
"ava": "^0.25.0",
"ava": "^1.1.0",
"cpx": "^1.5.0",
"eslint": "^5.12.1",
"eslint-plugin-import": "^2.15.0",
@@ -5,44 +5,54 @@ import * as path from 'path';
import { URL } from 'url';

import * as sinon from 'sinon';
import test, { GenericTestContext, Context } from 'ava';
import anyTest, { TestInterface, ExecutionContext } from 'ava';

import { createServer, ServerConfiguration } from '@hint/utils-create-server';
import { IConnector, IConnectorConstructor } from 'hint/dist/src/lib/types';
import { createServer, ServerConfiguration, Server } from '@hint/utils-create-server';
import { IConnector, Events, IConnectorConstructor } from 'hint/dist/src/lib/types';
import generateHTMLPage from 'hint/dist/src/lib/utils/misc/generate-html-page';
import ChromeConnector from '../src/connector';
import { Engine } from 'hint';

const name: string = 'chrome';

type CollectContext = {
engine: Engine<Events>;
engineEmitSpy: sinon.SinonSpy;
engineEmitAsyncSpy: sinon.SinonSpy;
server: Server;
};

const test = anyTest as TestInterface<CollectContext>;

test.beforeEach(async (t) => {
const engine = {
emit() { },
emitAsync() { }
};
const engine: Engine<Events> = {
emit(): boolean {
return false;
},
async emitAsync(): Promise<any> { }
} as any;

const server = createServer();
const server: Server = createServer();

await server.start();

sinon.spy(engine, 'emit');
sinon.spy(engine, 'emitAsync');
t.context.engineEmitSpy = sinon.spy(engine, 'emit');
t.context.engineEmitAsyncSpy = sinon.spy(engine, 'emitAsync');

t.context = {
engine,
server
};
t.context.server = server;
t.context.engine = engine;
});

test.afterEach.always((t) => {
t.context.server.stop();
t.context.engine.emit.restore();
t.context.engine.emitAsync.restore();
t.context.engineEmitSpy.restore();
t.context.engineEmitAsyncSpy.restore();
});

const pathToFaviconInDir = path.join(__dirname, './fixtures/common/favicon.ico');
const pathToFaviconInLinkElement = path.join(__dirname, './fixtures/common/favicon-32x32.png');

const runTest = async (t: GenericTestContext<Context<any>>, ConnectorConstructor: IConnectorConstructor, serverConfig?: ServerConfiguration) => {
const runTest = async (t: ExecutionContext<CollectContext>, ConnectorConstructor: IConnectorConstructor, serverConfig?: ServerConfiguration) => {
const { engine } = t.context;
const connector: IConnector = new ConnectorConstructor(engine, {});
const server = t.context.server;
@@ -60,7 +70,7 @@ test(`[${name}] The HTML is downloaded and the right event emitted`, async (t) =

await runTest(t, ChromeConnector, serverConfig);

t.is(t.context.engine.emitAsync.withArgs('fetch::end::html').callCount, 1);
t.is(t.context.engineEmitAsyncSpy.withArgs('fetch::end::html').callCount, 1);
});

test(`[${name}] Favicon is present in a 'link' element with 'rel' attribute set to 'icon' `, async (t) => {
@@ -72,8 +82,8 @@ test(`[${name}] Favicon is present in a 'link' element with 'rel' attribute set

await runTest(t, ChromeConnector, serverConfig);

t.is(t.context.engine.emitAsync.withArgs('fetch::end::image').callCount, 1);
t.is(t.context.engine.emitAsync.withArgs('fetch::end::image').args[0][1].request.url, faviconInLinkElementDir);
t.is(t.context.engineEmitAsyncSpy.withArgs('fetch::end::image').callCount, 1);
t.is(t.context.engineEmitAsyncSpy.withArgs('fetch::end::image').args[0][1].request.url, faviconInLinkElementDir);

});

@@ -83,8 +93,8 @@ test(`[${name}] Favicon is present in the root directory`, async (t) => {

await runTest(t, ChromeConnector, serverConfig);

t.is(t.context.engine.emitAsync.withArgs('fetch::end::image').callCount, 1);
t.is(t.context.engine.emitAsync.withArgs('fetch::end::image').args[0][1].request.url, faviconInRootDir);
t.is(t.context.engineEmitAsyncSpy.withArgs('fetch::end::image').callCount, 1);
t.is(t.context.engineEmitAsyncSpy.withArgs('fetch::end::image').args[0][1].request.url, faviconInRootDir);
});

test(`[${name}] Favicon is present in both the root directory and the 'link' element`, async (t) => {
@@ -97,9 +107,9 @@ test(`[${name}] Favicon is present in both the root directory and the 'link' ele

await runTest(t, ChromeConnector, serverConfig);

t.is(t.context.engine.emitAsync.withArgs('fetch::end::image').callCount, 1);
t.is(t.context.engineEmitAsyncSpy.withArgs('fetch::end::image').callCount, 1);
// Should load favicon from the link element if it exists
t.is(t.context.engine.emitAsync.withArgs('fetch::end::image').args[0][1].request.url, faviconInLinkElementDir);
t.is(t.context.engineEmitAsyncSpy.withArgs('fetch::end::image').args[0][1].request.url, faviconInLinkElementDir);
});

test(`[${name}] Favicon is present in both the root directory and the 'link' element, but the 'link' element has empty 'href'`, async (t) => {
@@ -111,9 +121,9 @@ test(`[${name}] Favicon is present in both the root directory and the 'link' ele

await runTest(t, ChromeConnector, serverConfig);

t.is(t.context.engine.emitAsync.withArgs('fetch::end::image').callCount, 1);
t.is(t.context.engineEmitAsyncSpy.withArgs('fetch::end::image').callCount, 1);
// Should load favicon from the root even though the link element exists because 'href' is empty.
t.is(t.context.engine.emitAsync.withArgs('fetch::end::image').args[0][1].request.url, faviconInRootDir);
t.is(t.context.engineEmitAsyncSpy.withArgs('fetch::end::image').args[0][1].request.url, faviconInRootDir);
});

test(`[${name}] Favicon is not present in either the root directory or the 'link' element`, async (t) => {
@@ -123,6 +133,6 @@ test(`[${name}] Favicon is not present in either the root directory or the 'link
await runTest(t, ChromeConnector, serverConfig);

// Requests to `/favicon.ico` are always sent when favicon doesn't exist as a `link` tag in the html.
t.is(t.context.engine.emitAsync.withArgs('fetch::end::image').callCount, 1);
t.is(t.context.engine.emitAsync.withArgs('fetch::end::image').args[0][1].request.url, faviconInRootDir);
t.is(t.context.engineEmitAsyncSpy.withArgs('fetch::end::image').callCount, 1);
t.is(t.context.engineEmitAsyncSpy.withArgs('fetch::end::image').args[0][1].request.url, faviconInRootDir);
});
@@ -1,12 +1,22 @@
import { URL } from 'url';

import test from 'ava';
import anyTest, { TestInterface } from 'ava';

import { createServer } from '@hint/utils-create-server';
import { createServer, Server } from '@hint/utils-create-server';
import generateHTMLPage from 'hint/dist/src/lib/utils/misc/generate-html-page';
import { IConnector } from 'hint/dist/src/lib/types';
import { IConnector, Events } from 'hint/dist/src/lib/types';
import { Engine } from 'hint';

import ChromeConnector from '../src/connector';

type EvaluateContext = {
connector: IConnector;
engine: Engine<Events>;
server: Server;
};

const test = anyTest as TestInterface<EvaluateContext>;

const name: string = 'chrome';

const scripts = [
@@ -46,20 +56,20 @@ const scripts = [
];

test.beforeEach(async (t) => {
const engine = {
emit() { },
emitAsync() { },
const engine: Engine<Events> = {
emit(): boolean {
return false;
},
async emitAsync(): Promise<any> { },
timeout: 10000
};
} as any;

const server = createServer();

await server.start();

t.context = {
engine,
server
};
t.context.engine = engine;
t.context.server = server;
});

test.afterEach.always(async (t) => {
@@ -72,9 +82,10 @@ test(`[${name}] Evaluate JavaScript`, async (t) => {
const connector: IConnector = new ChromeConnector(engine, {});
const server = t.context.server;

t.plan(scripts.length);
t.context.connector = connector;

t.plan(scripts.length);

server.configure(generateHTMLPage('', ''));

await connector.collect(new URL(`http://localhost:${server.port}/`));
@@ -10,14 +10,24 @@ import * as path from 'path';
import { URL } from 'url';

import { map, reduce, groupBy, every } from 'lodash';

import * as sinon from 'sinon';
import test from 'ava';

import anyTest, { TestInterface } from 'ava';
import { createServer, Server } from '@hint/utils-create-server';
import { IConnector } from 'hint/dist/src/lib/types';
import { IConnector, Events } from 'hint/dist/src/lib/types';
import { Engine } from 'hint';

import ChromeConnector from '../src/connector';

type EventsContext = {
connector?: IConnector;
engine: Engine<Events>;
engineEmitSpy: sinon.SinonSpy;
engineEmitAsyncSpy: sinon.SinonSpy;
server: Server;
};

const test = anyTest as TestInterface<EventsContext>;

const name: string = 'chrome';

/* eslint-disable sort-keys */
@@ -192,31 +202,30 @@ const validEvent = (eventsToSearch: any[], expectedEvent: any) => {
return originalSize !== eventsToSearch.length;
};


test.beforeEach(async (t) => {
const engine = {
emit() { },
emitAsync() { }
};
const engine: Engine<Events> = {
emit(): boolean {
return false;
},
async emitAsync(): Promise<any> { }
} as any;

sinon.spy(engine, 'emitAsync');
sinon.spy(engine, 'emit');
t.context.engineEmitAsyncSpy = sinon.spy(engine, 'emitAsync');
t.context.engineEmitSpy = sinon.spy(engine, 'emit');

const server: Server = createServer();

await server.start();

t.context = {
engine,
server
};
t.context.engine = engine;
t.context.server = server;
});

test.afterEach.always(async (t) => {
t.context.engine.emitAsync.restore();
t.context.engine.emit.restore();
t.context.engineEmitAsyncSpy.restore();
t.context.engineEmitSpy.restore();
t.context.server.stop();
await t.context.connector.close();
await t.context.connector!.close();
});

/**
@@ -283,15 +292,15 @@ test(`[${name}] Events`, async (t) => {

await connector.collect(new URL(`http://localhost:${server.port}/`));

const { emit, emitAsync } = t.context.engine;
const { engineEmitSpy, engineEmitAsyncSpy } = t.context;
const invokes: any[] = [];

for (let i = 0; i < emitAsync.callCount; i++) {
invokes.push(emitAsync.getCall(i).args);
for (let i = 0; i < engineEmitAsyncSpy.callCount; i++) {
invokes.push(engineEmitAsyncSpy.getCall(i).args);
}

for (let i = 0; i < emit.callCount; i++) {
invokes.push(emit.getCall(i).args);
for (let i = 0; i < engineEmitSpy.callCount; i++) {
invokes.push(engineEmitSpy.getCall(i).args);
}

// List of events that only have to be called once per execution
@@ -4,19 +4,30 @@ import * as fs from 'fs';
import * as path from 'path';
import { URL } from 'url';

import test from 'ava';
import anyTest, { TestInterface } from 'ava';
import { createServer, Server } from '@hint/utils-create-server';
import { IConnector, NetworkData, Events } from 'hint/dist/src/lib/types';
import { Engine } from 'hint';

import { createServer } from '@hint/utils-create-server';
import { IConnector, NetworkData } from 'hint/dist/src/lib/types';
import ChromeConnector from '../src/connector';

type FetchContentContext = {
connector?: IConnector;
engine: Engine<Events>;
server: Server;
};

const test = anyTest as TestInterface<FetchContentContext>;

const name: string = 'chrome';

test.beforeEach(async (t) => {
const engine = {
emit() { },
emitAsync() { }
};
const engine: Engine<Events> = {
emit(): boolean {
return false;
},
async emitAsync(): Promise<any> { }
} as any;

const server = createServer();

@@ -30,7 +41,7 @@ test.beforeEach(async (t) => {

test.afterEach.always(async (t) => {
t.context.server.stop();
await t.context.connector.close();
await t.context.connector!.close();
});

test(`[${name}] Fetch Content`, async (t) => {
Oops, something went wrong.

0 comments on commit 91b1e21

Please sign in to comment.
You can’t perform that action at this time.