diff --git a/apps/skolplattformen-sthlm/tsconfig.spec.json b/apps/skolplattformen-sthlm/tsconfig.spec.json index 559410b9..ba483824 100644 --- a/apps/skolplattformen-sthlm/tsconfig.spec.json +++ b/apps/skolplattformen-sthlm/tsconfig.spec.json @@ -10,6 +10,10 @@ "**/*.spec.tsx", "**/*.spec.js", "**/*.spec.jsx", + "**/*.test.ts", + "**/*.test.tsx", + "**/*.test.js", + "**/*.test.jsx", "**/*.d.ts" ] } diff --git a/libs/api-skolplattformen/.babelrc b/libs/api-skolplattformen/.babelrc new file mode 100644 index 00000000..ccae900b --- /dev/null +++ b/libs/api-skolplattformen/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + [ + "@nrwl/react/babel", + { + "runtime": "automatic", + "useBuiltIns": "usage" + } + ] + ], + "plugins": [] +} diff --git a/libs/api-skolplattformen/babel.config.js b/libs/api-skolplattformen/babel.config.js deleted file mode 100644 index eba83769..00000000 --- a/libs/api-skolplattformen/babel.config.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = function(api) { - api.cache(true); - const presets = [ - '@nrwl/next/babel', - 'module:metro-react-native-babel-preset' - ]; - const plugins = [ - ["@babel/plugin-proposal-private-property-in-object", { "loose": false }] - ]; - - return { - presets, - plugins - }; - }; \ No newline at end of file diff --git a/libs/api-skolplattformen/lib/index.ts b/libs/api-skolplattformen/lib/index.ts index ac9b7a0b..7ff3b1a1 100644 --- a/libs/api-skolplattformen/lib/index.ts +++ b/libs/api-skolplattformen/lib/index.ts @@ -1,19 +1,19 @@ import { Api } from './api' -import { FetcherOptions } from './fetcher' -import { Fetch } from './types' import { RNCookieManager, ToughCookieJar, wrapReactNativeCookieManager, wrapToughCookie, } from './cookies' +import { FetcherOptions } from './fetcher' +import { Fetch } from './types' -export { Api, FetcherOptions } -export * from './types' export { LoginStatusChecker } from './loginStatus' +export * from './types' +export { Api, FetcherOptions } const init = ( - fetch: Fetch, + fetchImpl: Fetch, cookieManagerImpl: RNCookieManager | ToughCookieJar, options?: FetcherOptions ): Api => { @@ -21,7 +21,7 @@ const init = ( const cookieManager = ((cookieManagerImpl as RNCookieManager).get) ? wrapReactNativeCookieManager(cookieManagerImpl as RNCookieManager) : wrapToughCookie(cookieManagerImpl as ToughCookieJar) - return new Api(fetch, cookieManager, options) + return new Api(fetchImpl, cookieManager, options) } export default init diff --git a/libs/api-skolplattformen/tsconfig.spec.json b/libs/api-skolplattformen/tsconfig.spec.json index 559410b9..ba483824 100644 --- a/libs/api-skolplattformen/tsconfig.spec.json +++ b/libs/api-skolplattformen/tsconfig.spec.json @@ -10,6 +10,10 @@ "**/*.spec.tsx", "**/*.spec.js", "**/*.spec.jsx", + "**/*.test.ts", + "**/*.test.tsx", + "**/*.test.js", + "**/*.test.jsx", "**/*.d.ts" ] } diff --git a/libs/curriculum/tsconfig.spec.json b/libs/curriculum/tsconfig.spec.json index 559410b9..ba483824 100644 --- a/libs/curriculum/tsconfig.spec.json +++ b/libs/curriculum/tsconfig.spec.json @@ -10,6 +10,10 @@ "**/*.spec.tsx", "**/*.spec.js", "**/*.spec.jsx", + "**/*.test.ts", + "**/*.test.tsx", + "**/*.test.js", + "**/*.test.jsx", "**/*.d.ts" ] } diff --git a/libs/hooks/.babelrc b/libs/hooks/.babelrc new file mode 100644 index 00000000..ccae900b --- /dev/null +++ b/libs/hooks/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + [ + "@nrwl/react/babel", + { + "runtime": "automatic", + "useBuiltIns": "usage" + } + ] + ], + "plugins": [] +} diff --git a/libs/hooks/babel.config.js b/libs/hooks/babel.config.js deleted file mode 100644 index 331417b6..00000000 --- a/libs/hooks/babel.config.js +++ /dev/null @@ -1,30 +0,0 @@ -module.exports = function(api) { - api.cache(true); - const presets = [ - [ - '@nrwl/next/babel', - { - modules: 'auto', - targets: { - browsers: ['defaults'] - }, - } - ], - "@nrwl/react/babel", - ]; - const plugins = [ - '@babel/plugin-transform-runtime', - '@babel/plugin-proposal-class-properties', - ["@babel/plugin-proposal-private-property-in-object", { "loose": false }], - "@babel/plugin-transform-runtime", - { - "regenerator": true, - "corejs": 3 - } - ]; - - return { - presets, - plugins - }; - }; \ No newline at end of file diff --git a/libs/hooks/jest.config.js b/libs/hooks/jest.config.js index be2c435a..293f4263 100644 --- a/libs/hooks/jest.config.js +++ b/libs/hooks/jest.config.js @@ -6,7 +6,4 @@ module.exports = { }, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], coverageDirectory: '../../coverage/libs/hooks', - testEnvironment: 'jsdom', - clearMocks: true, - setupFilesAfterEnv: ['/jest.setup.js'] } diff --git a/libs/hooks/jest.setup.js b/libs/hooks/jest.setup.js deleted file mode 100644 index abf6292e..00000000 --- a/libs/hooks/jest.setup.js +++ /dev/null @@ -1 +0,0 @@ -import 'regenerator-runtime/runtime' diff --git a/libs/hooks/package.json b/libs/hooks/package.json index 51d668c8..3242786e 100644 --- a/libs/hooks/package.json +++ b/libs/hooks/package.json @@ -19,5 +19,8 @@ }, "publishConfig": { "access": "public" + }, + "devDependencies": { + "jest": "*" } } diff --git a/libs/hooks/src/fake.test.js b/libs/hooks/src/fake.test.tsx similarity index 94% rename from libs/hooks/src/fake.test.js rename to libs/hooks/src/fake.test.tsx index 10722f54..0f848908 100644 --- a/libs/hooks/src/fake.test.js +++ b/libs/hooks/src/fake.test.tsx @@ -18,12 +18,12 @@ const { default: init } = jest.requireActual( '@skolplattformen/api-skolplattformen' ) -const wait = (ms) => new Promise((res) => setTimeout(res, ms)) +const wait = (ms: number) => new Promise((res) => setTimeout(res, ms)) describe('hooks with fake data', () => { - let api - let storage - const wrapper = ({ children }) => ( + let api: any + let storage: any + const wrapper = ({ children }: { children: React.ReactNode }) => ( {children} @@ -92,7 +92,7 @@ describe('hooks with fake data', () => { }) }) describe('data belonging to one child', () => { - let child + let child: any beforeEach(async () => { ;[child] = await api.getChildren() }) @@ -178,7 +178,7 @@ describe('hooks with fake data', () => { }) it('handles reloads', async () => { await act(async () => { - store.dispatch({ type: 'CLEAR' }) + store.dispatch({ type: 'CLEAR' } as any) // fixes test for invalid type const [child] = await api.getChildren() diff --git a/libs/hooks/tsconfig.spec.json b/libs/hooks/tsconfig.spec.json index 559410b9..ba483824 100644 --- a/libs/hooks/tsconfig.spec.json +++ b/libs/hooks/tsconfig.spec.json @@ -10,6 +10,10 @@ "**/*.spec.tsx", "**/*.spec.js", "**/*.spec.jsx", + "**/*.test.ts", + "**/*.test.tsx", + "**/*.test.js", + "**/*.test.jsx", "**/*.d.ts" ] } diff --git a/package.json b/package.json index a024cb3f..98bad385 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "@types/detox": "17.14.2", "@types/he": "^1.1.1", "@types/i18n-js": "^3.8.2", - "@types/jest": "26.0.24", + "@types/jest": "^27.0.2", "@types/luxon": "^1.26.4", "@types/node": "14.14.33", "@types/node-fetch": "^2.5.10", diff --git a/tsconfig.base.json b/tsconfig.base.json index 55d42216..309d4e0d 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -20,6 +20,5 @@ "@skolplattformen/curriculum": ["libs/curriculum/src/index.ts"], "@skolplattformen/hooks": ["libs/hooks/src/index.ts"] } - }, - "exclude": ["node_modules", "tmp"] + } } diff --git a/yarn.lock b/yarn.lock index 6de26351..dbd28b93 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2535,7 +2535,7 @@ dependencies: "@types/istanbul-lib-report" "*" -"@types/jest@*", "@types/jest@26.0.24": +"@types/jest@*": version "26.0.24" resolved "https://registry.npmjs.org/@types/jest/-/jest-26.0.24.tgz" integrity sha512-E/X5Vib8BWqZNRlDxj9vYXhsDwPYbPINqKF9BsnSoon4RQ0D9moEuLD8txgyypFLH7J4+Lho9Nr/c8H0Fi+17w== @@ -2543,6 +2543,14 @@ jest-diff "^26.0.0" pretty-format "^26.0.0" +"@types/jest@^27.0.2": + version "27.0.2" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-27.0.2.tgz#ac383c4d4aaddd29bbf2b916d8d105c304a5fcd7" + integrity sha512-4dRxkS/AFX0c5XW6IPMNOydLn2tEhNhJV7DnYK+0bjoJZ+QTmfucBlihX7aoEsh/ocYtkLC73UbnBXBXIxsULA== + dependencies: + jest-diff "^27.0.0" + pretty-format "^27.0.0" + "@types/json-schema@^7.0.4", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.7", "@types/json-schema@^7.0.8": version "7.0.9" resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz" @@ -8189,7 +8197,7 @@ jest-diff@^26.0.0: jest-get-type "^26.3.0" pretty-format "^26.6.2" -jest-diff@^27.2.5: +jest-diff@^27.0.0, jest-diff@^27.2.5: version "27.2.5" resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-27.2.5.tgz#908f7a6aca5653824516ad30e0a9fd9767e53623" integrity sha512-7gfwwyYkeslOOVQY4tVq5TaQa92mWfC9COsVYMNVYyJTOYAqbIkoD3twi5A+h+tAPtAelRxkqY6/xu+jwTr0dA== @@ -11368,7 +11376,7 @@ pretty-format@^26.0.0, pretty-format@^26.0.1, pretty-format@^26.5.2, pretty-form ansi-styles "^4.0.0" react-is "^17.0.1" -pretty-format@^27.2.2, pretty-format@^27.2.5: +pretty-format@^27.0.0, pretty-format@^27.2.2, pretty-format@^27.2.5: version "27.2.5" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.2.5.tgz#7cfe2a8e8f01a5b5b29296a0b70f4140df0830c5" integrity sha512-+nYn2z9GgicO9JiqmY25Xtq8SYfZ/5VCpEU3pppHHNAhd1y+ZXxmNPd1evmNcAd6Hz4iBV2kf0UpGth5A/VJ7g==