diff --git a/package.json b/package.json index dc5f477b..1695abac 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "@semantic-release/github": "^7.2.0", "@semantic-release/npm": "^7.0.10", "@semantic-release/release-notes-generator": "^9.0.1", - "@testing-library/dom": "^7.29.4", + "@testing-library/dom": "^7.29.6", + "@testing-library/jest-dom": "^5.11.9", "@typeform/eslint-config": "^3.0.2", "@types/cypress": "^1.1.3", "@types/jest": "^26.0.20", diff --git a/packages/embed/jest-setup.ts b/packages/embed/jest-setup.ts new file mode 100644 index 00000000..c44951a6 --- /dev/null +++ b/packages/embed/jest-setup.ts @@ -0,0 +1 @@ +import '@testing-library/jest-dom' diff --git a/packages/embed/jest.config.json b/packages/embed/jest.config.json index c3100e88..884829b8 100644 --- a/packages/embed/jest.config.json +++ b/packages/embed/jest.config.json @@ -4,5 +4,6 @@ "^.+\\.(ts|tsx)$": "ts-jest" }, "testMatch": ["**/src/**/*.spec.(ts|tsx)"], - "coverageReporters": [["lcov", { "projectRoot": "../.." }]] + "coverageReporters": [["lcov", { "projectRoot": "../.." }]], + "setupFilesAfterEnv": ["/jest-setup.ts"] } diff --git a/packages/embed/src/factories/create-popup/create-popup.spec.ts b/packages/embed/src/factories/create-popup/create-popup.spec.ts index 6ce5ea80..95bf0500 100644 --- a/packages/embed/src/factories/create-popup/create-popup.spec.ts +++ b/packages/embed/src/factories/create-popup/create-popup.spec.ts @@ -28,8 +28,8 @@ describe('create-popup', () => { it('should render the popup', () => { const popupElement = container.querySelector('.typeform-popup') as HTMLElement const wrapper = popupElement.querySelector('.typeform-iframe-wrapper') as HTMLElement - expect(popupElement).toBeTruthy() - expect(popupElement.querySelector('.typeform-spinner')).toBeTruthy() + expect(popupElement).toBeVisible() + expect(popupElement.querySelector('.typeform-spinner')).toBeVisible() expect(wrapper.querySelector('iframe')).toBeTruthy() expect(wrapper.querySelector('.typeform-close')).toBeTruthy() expect(wrapper.style.width).toBe('200px') diff --git a/packages/embed/tsconfig.json b/packages/embed/tsconfig.json index 2e67520f..c8203acc 100644 --- a/packages/embed/tsconfig.json +++ b/packages/embed/tsconfig.json @@ -25,5 +25,5 @@ "typeRoots": ["./types", "./node_modules/@types"], "types": ["@types/jest", "node"] }, - "include": ["src/**/*.ts*"] + "include": ["src/**/*.ts*", "./jest-setup.ts"] } diff --git a/yarn.lock b/yarn.lock index 0cf7e6ee..2b260c7b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1430,6 +1430,13 @@ dependencies: regenerator-runtime "^0.13.4" +"@babel/runtime@^7.9.2": + version "7.13.9" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.9.tgz#97dbe2116e2630c489f22e0656decd60aaa1fcee" + integrity sha512-aY2kU+xgJ3dJ1eU6FMB9EH8dIe8dmusF1xEku52joLvw6eAFN0AI+WxCLDnpev2LEejWBAy2sBvBOBAjI3zmvA== + dependencies: + regenerator-runtime "^0.13.4" + "@babel/template@^7.10.4", "@babel/template@^7.12.7", "@babel/template@^7.3.3": version "7.12.7" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.12.7.tgz#c817233696018e39fbb6c491d2fb684e05ed43bc" @@ -3317,10 +3324,10 @@ "@svgr/plugin-svgo" "^5.5.0" loader-utils "^2.0.0" -"@testing-library/dom@^7.29.4": - version "7.29.4" - resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-7.29.4.tgz#1647c2b478789621ead7a50614ad81ab5ae5b86c" - integrity sha512-CtrJRiSYEfbtNGtEsd78mk1n1v2TUbeABlNIcOCJdDfkN5/JTOwQEbbQpoSRxGqzcWPgStMvJ4mNolSuBRv1NA== +"@testing-library/dom@^7.29.6": + version "7.29.6" + resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-7.29.6.tgz#eb37844fb431186db7960a7ff6749ea65a19617c" + integrity sha512-vzTsAXa439ptdvav/4lsKRcGpAQX7b6wBIqia7+iNzqGJ5zjswApxA6jDAsexrc6ue9krWcbh8o+LYkBXW+GCQ== dependencies: "@babel/code-frame" "^7.10.4" "@babel/runtime" "^7.12.5" @@ -3331,13 +3338,27 @@ lz-string "^1.4.4" pretty-format "^26.6.2" +"@testing-library/jest-dom@^5.11.9": + version "5.11.9" + resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-5.11.9.tgz#e6b3cd687021f89f261bd53cbe367041fbd3e975" + integrity sha512-Mn2gnA9d1wStlAIT2NU8J15LNob0YFBVjs2aEQ3j8rsfRQo+lAs7/ui1i2TGaJjapLmuNPLTsrm+nPjmZDwpcQ== + dependencies: + "@babel/runtime" "^7.9.2" + "@types/testing-library__jest-dom" "^5.9.1" + aria-query "^4.2.2" + chalk "^3.0.0" + css "^3.0.0" + css.escape "^1.5.1" + lodash "^4.17.15" + redent "^3.0.0" + "@tootallnate/once@1": version "1.1.2" resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== "@typeform/embed@file:packages/embed": - version "1.0.0-next.2" + version "1.0.0-next.11" "@typeform/eslint-config@^3.0.2": version "3.0.2" @@ -3476,7 +3497,7 @@ dependencies: "@types/istanbul-lib-report" "*" -"@types/jest@26.x", "@types/jest@^26.0.20": +"@types/jest@*", "@types/jest@26.x", "@types/jest@^26.0.20": version "26.0.20" resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.20.tgz#cd2f2702ecf69e86b586e1f5223a60e454056307" integrity sha512-9zi2Y+5USJRxd0FsahERhBwlcvFh6D2GLQnY2FH2BzK8J9s9omvNHIbvABwIluXa0fD8XVKMLTO0aOEuUfACAA== @@ -3566,6 +3587,13 @@ resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.6.tgz#a9ca4b70a18b270ccb2bc0aaafefd1d486b7ea74" integrity sha512-W+bw9ds02rAQaMvaLYxAbJ6cvguW/iJXNT6lTssS1ps6QdrMKttqEAMEG/b5CR8TZl3/L7/lH0ZV5nNR1LXikA== +"@types/testing-library__jest-dom@^5.9.1": + version "5.9.5" + resolved "https://registry.yarnpkg.com/@types/testing-library__jest-dom/-/testing-library__jest-dom-5.9.5.tgz#5bf25c91ad2d7b38f264b12275e5c92a66d849b0" + integrity sha512-ggn3ws+yRbOHog9GxnXiEZ/35Mow6YtPZpd7Z5mKDeZS/o7zx3yAle0ov/wjhVB5QT4N2Dt+GNoGCdqkBGCajQ== + dependencies: + "@types/jest" "*" + "@types/uglify-js@*": version "3.12.0" resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.12.0.tgz#2bb061c269441620d46b946350c8f16d52ef37c5" @@ -5489,7 +5517,7 @@ chalk@2.4.2, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.3.1, chalk@^2.3.2, chalk@^2.4. escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@3.0.0: +chalk@3.0.0, chalk@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4" integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg== @@ -6501,7 +6529,7 @@ css-what@^3.2.1: resolved "https://registry.yarnpkg.com/css-what/-/css-what-3.4.2.tgz#ea7026fcb01777edbde52124e21f327e7ae950e4" integrity sha512-ACUm3L0/jiZTqfzRM3Hi9Q8eZqd6IK37mMWPLz9PJxkLWllYeRf+EHUSHYEtFop2Eqytaq1FizFVh7XfBnXCDQ== -css.escape@1.5.1: +css.escape@1.5.1, css.escape@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/css.escape/-/css.escape-1.5.1.tgz#42e27d4fa04ae32f931a4b4d4191fa9cddee97cb" integrity sha1-QuJ9T6BK4y+TGktNQZH6nN3ul8s= @@ -6516,6 +6544,15 @@ css@^2.0.0: source-map-resolve "^0.5.2" urix "^0.1.0" +css@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/css/-/css-3.0.0.tgz#4447a4d58fdd03367c516ca9f64ae365cee4aa5d" + integrity sha512-DG9pFfwOrzc+hawpmqX/dHYHJG+Bsdb0klhyi1sDneOgGOXy9wQIC8hzyVp1e4NRYDBdxcylvywPkkXCHAzTyQ== + dependencies: + inherits "^2.0.4" + source-map "^0.6.1" + source-map-resolve "^0.6.0" + cssdb@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/cssdb/-/cssdb-4.4.0.tgz#3bf2f2a68c10f5c6a08abd92378331ee803cddb0" @@ -16173,6 +16210,14 @@ source-map-resolve@^0.5.0, source-map-resolve@^0.5.2: source-map-url "^0.4.0" urix "^0.1.0" +source-map-resolve@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.6.0.tgz#3d9df87e236b53f16d01e58150fc7711138e5ed2" + integrity sha512-KXBr9d/fO/bWo97NXsPIAW1bFSBOuCnjbNTBMO7N59hsv5i9yzRDfcYwwt0l04+VqnKC+EwzvJZIP/qkuMgR/w== + dependencies: + atob "^2.1.2" + decode-uri-component "^0.2.0" + source-map-support@^0.5.6, source-map-support@~0.5.12, source-map-support@~0.5.19: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61"