diff --git a/jest-circus-setup.js b/jest-circus-setup.js new file mode 100644 index 0000000..1935853 --- /dev/null +++ b/jest-circus-setup.js @@ -0,0 +1,2 @@ +// Shim for angular-mocks +window.jasmine = window.jasmine || {}; \ No newline at end of file diff --git a/package.json b/package.json index a56cb07..250d664 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Simple and complete AngularJS testing utilities that encourage good testing practices.", "main": "lib/index.js", "engines": { - "node": ">=10" + "node": ">=12" }, "scripts": { "prebuild": "rimraf lib", @@ -62,29 +62,30 @@ ], "license": "MIT", "dependencies": { - "@testing-library/dom": "^6.3.0" + "@testing-library/dom": "^8.5.0" }, "devDependencies": { "@semantic-release/git": "^7.0.17", "@testing-library/jest-dom": "^4.1.0", "@types/angular": "^1.6.57", "@types/angular-mocks": "^1.7.0", - "@types/jest": "^24.0.23", + "@types/jest": "^27.0.1", "@types/node": "^12.12.16", - "@typescript-eslint/parser": "^2.11.0", + "@typescript-eslint/parser": "^4.31.1", "angular": "^1.7.8", "angular-mocks": "^1.7.8", "concurrently": "^5.0.0", "doctoc": "^1.4.0", - "eslint": "^6.7.2", + "eslint": "^7.32.0", "husky": "^3.1.0", - "jest": "^24.9.0", - "jest-cli": "^24.9.0", + "jest": "^27.2.0", + "jest-cli": "^27.2.0", "lint-staged": "^9.5.0", + "prettier": "^2.4.0", "rimraf": "^3.0.0", "semantic-release": "^15.13.30", - "ts-jest": "^24.2.0", - "typescript": "^3.7.3" + "ts-jest": "^27.0.5", + "typescript": "^4.4.3" }, "peerDependencies": { "angular": "*", @@ -122,7 +123,9 @@ "jest": { "preset": "ts-jest", "setupFilesAfterEnv": [ - "@testing-library/jest-dom/extend-expect" - ] + "@testing-library/jest-dom/extend-expect", + "/jest-circus-setup.js" + ], + "testEnvironment": "jsdom" } } diff --git a/src/__tests__/auto-cleanup-skip.ts b/src/__tests__/auto-cleanup-skip.ts index 26f76b9..506ee0d 100644 --- a/src/__tests__/auto-cleanup-skip.ts +++ b/src/__tests__/auto-cleanup-skip.ts @@ -1,9 +1,4 @@ -let render: (html: string) => void -beforeAll(() => { - process.env.ATL_SKIP_AUTO_CLEANUP = 'true' - const atl = require('../') - render = atl.render -}) +import {render} from '../pure'; // This one verifies that if ATL_SKIP_AUTO_CLEANUP is set // then we DON'T auto-wire up the afterEach for folks diff --git a/src/index.ts b/src/index.ts index 91a09d2..da18e52 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import {flush, cleanup} from './pure' +import { cleanup} from './pure' declare function afterEach(cb: () => void): void @@ -9,7 +9,6 @@ declare function afterEach(cb: () => void): void // or set the ATL_SKIP_AUTO_CLEANUP env variable to 'true'. if (typeof afterEach === 'function' && !process.env.ATL_SKIP_AUTO_CLEANUP) { afterEach(() => { - flush() cleanup() }) } diff --git a/src/pure.ts b/src/pure.ts index 9509a5f..f93afb3 100644 --- a/src/pure.ts +++ b/src/pure.ts @@ -11,7 +11,7 @@ import { getQueriesForElement, prettyDOM, fireEvent as dtlFireEvent, - wait as dtlWait, + waitFor as dtlWait, queries as dtlQueries, Queries, BoundFunction, diff --git a/tsconfig.json b/tsconfig.json index 4e9c95c..09c8c48 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,10 +2,8 @@ "compilerOptions": { /* Basic Options */ "incremental": true /* Enable incremental compilation */, - "target": - "es2019" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */, - "module": - "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, + "target": "es2021" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */, + "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, // "lib": [], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ @@ -41,8 +39,7 @@ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ /* Module Resolution Options */ - "moduleResolution": - "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, + "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ // "paths": { // "src/*": ["/dev/null"], // Enforce relative paths