Skip to content

Commit 75486bd

Browse files
author
Mark George
committed
Get the tests working
1 parent 8e352e4 commit 75486bd

8 files changed

+30
-150
lines changed

jest.config.js

-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
module.exports = {
22
testMatch: [ '**/?(*.)+(spec|test).js' ],
3-
transform: {
4-
"^.+\\.ts?$": "ts-jest"
5-
},
63
setupFilesAfterEnv: [ './tests/config/jest-setup.js' ],
7-
collectCoverageFrom: [ 'lib/**/*.ts', 'index.ts' ],
84
globalSetup: 'jest-environment-puppeteer/setup',
95
globalTeardown: 'jest-environment-puppeteer/teardown',
106
testEnvironment: 'jest-environment-puppeteer',

lib/generate-critical-css.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ export async function generateCriticalCSS( {
148148
successRatio = 1,
149149
}: {
150150
browserInterface: BrowserInterface;
151-
progressCallback: ( step: number, total: number ) => void;
151+
progressCallback?: ( step: number, total: number ) => void;
152152
urls: string[];
153153
viewports: Viewport[];
154-
filters: FilterSpec;
154+
filters?: FilterSpec;
155155
successRatio?: number;
156156
} ): Promise< [ string, Error[] ] > {
157157
const successUrlsThreshold = Math.ceil( urls.length * successRatio );

lib/style-ast.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,7 @@ export class StyleAST {
542542
}
543543

544544
// Gather family-name values.
545-
const lexer: {
546-
findDeclarationValueFragments: Function;
547-
} = csstree as any;
545+
const lexer = ( csstree as any ).lexer;
548546
const frags = lexer.findDeclarationValueFragments(
549547
node,
550548
'Type',

package-lock.json

-131
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"rollup-plugin-polyfill-node": "^0.8.0",
4949
"rollup-plugin-terser": "^7.0.2",
5050
"stream-http": "^3.2.0",
51-
"ts-jest": "^28.0.8",
5251
"ts-loader": "^9.3.1",
5352
"tsconfig-paths-webpack-plugin": "^4.0.0",
5453
"typescript": "^4.7.4",

tests/data/webpack-wrap/webpack.config.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ module.exports = {
1111
filename: 'main.js',
1212
},
1313
module: {
14-
rules: [ {
15-
test: /\.ts$/,
16-
loader: 'ts-loader',
17-
} ],
14+
rules: [
15+
{
16+
test: /\.ts?$/,
17+
use: 'ts-loader',
18+
exclude: /node_modules/,
19+
},
20+
],
1821
},
1922
target: 'web',
2023
performance: {

tests/unit/generate-critical-css.test.js tests/unit/generate-critical-css.test.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
/* global browser */
22

3-
const { generateCriticalCSS, BrowserInterfacePuppeteer } = require( '../../index' );
3+
declare global {
4+
namespace jest {
5+
const mock: any;
6+
}
7+
8+
const expect: any;
9+
const describe: any;
10+
const beforeAll: any;
11+
const afterAll: any;
12+
const it: any;
13+
}
14+
15+
import { generateCriticalCSS, BrowserInterfacePuppeteer } from '../../index';
416
const { dataUrl } = require( '../lib/data-directory' );
517
const mockFetch = require( '../lib/mock-fetch' );
618
const path = require( 'path' );
@@ -12,7 +24,7 @@ const testPageUrls = {
1224
pageA: path.join( dataUrl, 'page-a/index.html' ),
1325
};
1426

15-
let testPages = {};
27+
let testPages: { [ key: string ]: any } = {};
1628

1729
/**
1830
* Run a batch of CSS generation test runs, verify the results contain (and do not contain) specific substrings.

tsconfig.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
2-
"include": [ "index.ts", "lib/*" ],
2+
"include": [ "index.ts", "lib/*", "tests/data/webpack-wrap/*" ],
33
"esModuleInterop": true,
44
"compilerOptions": {
5-
"target": "ESNext",
6-
"sourceMap": true
5+
"target": "es6",
6+
"module": "es6",
7+
"sourceMap": true,
8+
"allowJs": true,
9+
"moduleResolution": "node",
710
}
811
}

0 commit comments

Comments
 (0)