#Jest
Had the fortune to visit "Vermeer's Delft" (Het #Delft van #Vermeer) today. There's a lot to be said about it, all mostly good observations. But that's not what this toot's about. I'm here to bring to You the "ugly children of #art" mini #contest.
Of course, this is meant as a #jest in #goodfaith. Also, the images have nothing in common with the great artist, Johannes.




🚀 Support your #techdebt remediation efforts with code coverage data from multiple tools!
Check out our blog post for tips and tricks.



Do you have any tips on writing unit tests? How does one get better at making unit tests? or testing in general? seems like such a pain in the caboose I am using #jest at the moment should I just learn the framework more? trying to mock everything seems to take me an eternity sometimes.
Unit testing #EcmaScript module code with #Jest and #Typescript is a #PITA.
https://github.com/vitest-dev/vitest - Vitest: it's like #Jest but using #Vite loader, so no need for vue-jest, ts-node, etc, etc. And it loads with Vite, so it's fast. Runner in #VSCode: https://marketplace.visualstudio.com/items?itemName=ZixuanChen.vitest-explorer

https://vuesome.dev/articles/add-testing-to-vite/ - setup #testing with #Jest and #Cypress for a #Vite, #Vue3, & #TypeScript. Great tutorial https://github.com/vuesomedev.
🚀 Support your technical debt remediation efforts with code coverage data from multiple tools!
Check out our blog post for tips and tricks.



#Angular CLI 16 introduces experimental first-class #Jest support with the @angular-devkit/build-angular:jest builder https://blog.angular.io/moving-angular-cli-to-jest-and-web-test-runner-ef85ef69ceca
If you haven’t changed Jest's defaults your tests might be fragile, order-dependent, or just downright wrong. Check out my blog post where I dig into Jest's settings, and how you can fix your tests.
#javascript #node #jest #testing #unittest
https://jamiemagee.co.uk/blog/your-jest-tests-might-be-wrong/
#Angular v16 launched today!
This is a feature-PACKED release including:
🚦 Signals in developer preview.
➡️ Required inputs.
💧 Non-destructive hydration in developer preview.
🧍♀️ Standalone APIs for #Universal and improved schematics.
🛠️ Faster builds with #ESBuild and #Vite in developer preview.
🃏 Experimental #Jest support.
🅰️ ... and way more!
Check out our blog post for all the deets.
Re: Moving #Angular CLI to #Jest and Web Test Runner:
I'm having mixed feeling about this. Deprecating Karma makes sense. Its architecture is 10+ yrs old. But since Facebook handed Jest over to the community, Jest is seriously under-maintained. It has become the proverbial project some random person in Nebraska is thanklessly maintaining.
If the Angular team is serious about this switch, Google should pay someone contributing to Jest.
https://techhub.social/@develwithoutacause/110272255733926133
https://dev.to/darkmavis1980/how-to-mock-environmental-variables-with-jest-2j3c - set env vars for #Jest tests:
```
// jest.config.js
module.exports = {
setupFiles: ['<rootDir>/.jest/setEnvVars.js'],
...
}
```
Great quick tip https://github.com/darkmavis1980.

Here is our latest article on combining code coverage metrics from multiple #JavaScript tools to get the right info.
We explore how you can use IstanbulJS and nyc to combine code coverage details from #Jest and #Cypress
Check it out! https://go.upgradejs.com/0en #Testing #IstanbulJS #TechDebt
ICYMI: Stan Popovych published an article in the UpgradeJS blog about combining code coverage metrics from multiple #JavaScript tools to get the right info.
Check it out!
What happens when you have multiple tools testing your JavaScript app and you want a combined code coverage report?
In this article we explain how to combine code coverage data from multiple tools.
#testing #JavaScript #Jest #Cypress https://www.upgradejs.com/blog/testing/combining-code-coverage-data-from-multiple-testing-tools.html?utm_source=LinkedIn&utm_medium=post&utm_campaign=code-coverage&utm_term=combined&utm_content=multiple-tools&utm_id=


https://dev.to/ddoice/fix-slow-tests-with-jest-in-github-actions-5h00 - specify the number of CPUs to use in #Jest tests: `npm run test -- --maxWorkers=2` Great performance gain if you don't need the machine to do other things like support a UI desktop. Nice find https://github.com/ddoice.

#Angular announcement: We're moving Angular to #Jest and #WebTestRunner.
We've seen a lot of movement in the web testing ecosystem towards Jest and want to make it more available for #AngularCLI users.
We've also been particular impressed with Web Test Runner and are looking forward to bringing it into the Angular ecosystem as well.
Check out the #AngularBlog for all the details:
https://medium.com/angular-blog/moving-angular-cli-to-jest-and-web-test-runner-ef85ef69ceca
I feel like I'm going insane today. I just found a global variable in #NodeJS which is apparently _not_ a global? #Jest #ESM documentation states that the `jest` symbol is _not_ exposed globally and you have to import it, but sometimes it sort-of is?
```
console.log(typeof jest); // object
console.log(jest); // object
console.log(globalThis.jest); // undefined - WTF?!?!
```
Not only that, but `jest` is only defined in certain files and not others, even when one directly imports another.
This kind of behavior should be impossible and I'm completely perplexed. Is this something with `--experimental-vm-modules` or do I need to check myself into a mental hospital?
My latest (and greatest) book, JavaScript All-in-One For Dummies, is available now!
Every junior developer or aspiring JS developer needs this book, imho.
The book teaches modern #JavaScript, how browsers work, using #VSCode like a pro, #Git, #prettier, #eslint, #vite, #webpack, #react, #vue, #svelte, #http, #jest, #node, #express, #mongodb, #mongoose, and finishes with a chapter on authentication with #jwt.
It took me 6 months to write and is over 800 pages.
Your jest tests are (probably) wrong.
Add this to your jest config to prevent leaking state between tests.

what do you use (if you do!) for #JS/#TS #SnapshotTests?
Currently working on a TS #Vue 2.7.x project. Leaning towards using #Jest, but are there better options? I see #Playwright has snapshot capabilities as well.
Update: Bug in npm, see https://github.com/npm/cli/issues/4232, have to delete package.json and node_modules before
I upgraded #TS to "^5.0.2" in my package.json but #Jest (ts-jest@27.1.5 to be specific) requires typescript@">=3.8 <5.0". I've added to my package.json an overrides section:
"overrides": {
"typescript": "$typescript"
}
But #npm just keeps #whining about the conflicting peer dependencies.
Suggestions appreciated :)
*Why not just upgrade to Jest 29? There is a known issue with the #Vue CLI
@jasongorman Watching this now, it's interesting. I've been using GPT-3.5 to help with generate some #angular unit tests, since it's been a couple of years since I've written any angular myself. It's been fairly positive albeit a little hit and miss. It's almost like pair programming with a junior dev, who's good at spotting missing brackets. It also constantly forgets to use #jest tests rather than #jasmine.
Next issue with my #angular project is to fix some more of my tests. Most of them seem to be an issue with #NgRx. I have components using Entity Services, (EntityCollectionServiceBase) and I just can't get the #Jest test set up properly to inject them. And I can't find a decent example.
Anyway, time to park it for the evening.
Everyone wants to add tools to the dev env, but nobody wants to support their team when they break the precommit hooks. #eslint #typescript #jest #tdd #danger #testCoverage #linting #husky
I've managed to get the #Jest tests running, though about half are now having issues with paths and not finding modules.
Para aquellos que usen Jest en su proyecto y además lo tengan integrado en la CI recomiendo encarecidamente actualizar a la versión 28 ya que en dicha versión añadieron la posibilidad de usar shards, bien pues aprovechando esta funcionalidad podemos dividir y ejecutar dichas partes en paralelo dentro de nuestra CI para reducir considerablemente el tiempo de ejecución de nuestros tests 🚀
Dejo artículo dónde se muestra dicha implementación: https://remarkablemark.org/blog/2022/05/13/jest-shard-test-github-actions/
I just finished the final review of my new book (coming in May): JavaScript All-In-One For Dummies. This one has been my dream to write for over a decade, and I've been working on it for 10 months.
When I used to hire junior developers, I'd find myself (and them) overwhelmed with how much they had to know to be to be productive. This book addresses that.
#JavaScript #Git #vscode #React #Vue #Svelte #ESLint #Jest #Node #webapi #express #mongodb #webpack #babel #vite #rest #jwt #micdrop
#JavaScript and #nextjs friends. #Next allows for async server side components. react-testing-library and #jest seem to very much hate the idea of a `Promise<JSX.Element>` for any rendering. Any thoughts on proper ways to test async server components?
Having made significant progress on a large migration from #Jest to #Vitest, I can add our experience as an anecdote to the conversation about performance between the two!
Our component library saw about a 20% improvement in total time to run the tests, from about a little over 50 seconds to about 40. Not a huge win, but not bad!
An app that did the same migration showed even better improvements though, reducing the time spent by half; what used to take two minutes now takes less than one!
I really like Java and Eclipse, but #TypeScript with #Jest in #VSCode, executing my tests on every change in the background and showing me missing test coverage right in the text editor is hard to beat.
Spent the end of last week helping our frontend devs speed up their build/test/deploy times. I'm a bit rusty on #typescript and #javascript in general but it seems every year these systems add another layer of complexity. It's been a fun couple of days though poking around #yarn #webpack and #jest and hopefully the team are happy with significantly faster builds.
So I've been doing a bit of research into #web #UnitTesting #tooling (#Jest, #Vitest, #Jasmine, #Karma, #WebTestRunner, ...).
I'm curious if there's any interest in a blog post on some of my takeaways about aspects like:
* Test runners vs test frameworks.
* Browser-based runners vs Node-based runners.
* Changes in the ecosystem.
* Future directions of JS unit testing.
* ...
Day 246 #100daysofhomelab
Spent the time updating littlelink-server and fixing unit tests. Not the most exciting work, but necessary nonetheless. Fresh docker container building in CI now!
https://github.com/techno-tim/littlelink-server
#opensource #homelab #nodejs #react #node #reactjs #razzle #unitests #jest #docker #dockercontainer #selfhost #selfhosting #selfhosted #ci #cd #cicd
I asked #ChatGPT what some of the best articles on testing #Vue 2.x using #Jest were and it responded...all of the links are broken. 😂
Don't get me wrong, I'm still querying ChatGPT when Google isn't providing me with the desired answers
BUT what I'd really like is some #HumanAugmented #Search 😉
@eliajf I was mostly looking into test runners moreso than test frameworks.
#Jest is still dominant by a huge amount, but #WebTestRunner and #JasmineBrowserRunner looked interesting to me. I've had good experiences with WTR in the past, but haven't tried Jasmine's browser runner.
https://modern-web.dev/docs/test-runner/overview/
https://www.npmjs.com/package/jasmine-browser-runner
Working on fixing a bunch of failing tests? Try using --bail to stop Jest after the first failing test so you can tackle them one by one. #jest #javascript #react
Episode 23/04: https://youtu.be/Vm7etXJGNoQ
TypeScript released the beta for version 5, with stable support for decorators. They are slightly different from the experimental ones we use in Angular. Furthermore, Minko Gechev gave an update about Angular's roadmap. The focus in 2023 is on reactivity and server-side rendering.
#TypeScript 5 Beta: https://devblogs.microsoft.com/typescript/announcing-typescript-5-0-beta/
#Angular Roadmap 2023: https://youtu.be/7dm4Gif7A5o
Minor Releases:
- #NgRx 15.2 - support for functional creators: https://github.com/ngrx/platform/blob/master/CHANGELOG.md#1520-2023-01-26
- #Nx 15.6: https://github.com/nrwl/nx/releases/tag/15.6.0
- #Cypress 12.4: https://docs.cypress.io/guides/references/changelog#12-4-0
- #Playwright 1.30: https://github.com/microsoft/playwright/releases/tag/v1.30.0
- #Jest 29.4: https://github.com/facebook/jest/releases/tag/v29.4.0
Just fixing a warning from Jest has improved a unit test suite from 120 seconds of runtime down to 25. Don't ignore your warnings folks! #programming #testing #jest
One of the slightly punk ideas I had for JestSpec was to allow specifications written outside of pure Gherkin syntax, so you could write more naturally if you wanted to.
If you use #Jest with #JavaScript or #TypeScript you can use JestSpec to add #Gherkin, or natural language, specification files.
Go write some test prose!
https://www.stevefenton.co.uk/blog/2023/01/using-jestspec-without-gherkin/
Spent some time trying to get #Jest to work for our #ExpressJS app that runs in a #DockerCompose set-up. Failing miserably. I know it shouldn’t be this hard. I think I’m going to give up on the approach I was trying and just focus on endpoint testing, if I can figure out how to do that. I miss #Laravel at times like this.
Anyone have any recommendations on react component testing and mocking API-responses?
I'd preferably like to mock out the hook calling the query. Bonus if there are helps specifically for react-query
Published my first #npm #ESLint package. I’ve contributed to ESLint before, but never actually published my own package.
It was not bad at all. It took about 2 hours.
The rule is really simple and not useful to most people, but it was a nice way to ensure that we don’t forget to add #a11y #axe #jest tests to our test files and I can imagine it being useful for other similar code-hygiene patterns some day: https://github.com/katerberg/eslint-plugin-file-contains
Writing tests for this with ts-mocha instead of #jest, and at first glance it feels so much faster. I wonder the effort required is to convert a larger codebase...
Would love to hear from anybody else using ts-mocha instead of jest for #TypeScript.
Trying to use Jest and TypeScript is really frustrating. I have a Jest `expect ...` assertion that checks a value, but then I have to write a separate TS expression to narrow the type that Jest just checked.
For example, "expect(stringOrNumber).toBe('x')". At this point Jest has determined that it's a string, but TS still requires me to do "if (typeof stringOrNumber === 'string') ..."
Is there a better pattern? Or a testing library that does type narrowing?
Learn why Jest breaks the `instanceof` operator
https://backend.cafe/should-you-use-jest-as-a-testing-library
#EsNextNews #EcmaScript #JavaScript #Jest
We are looking for a #JavaScript Developer at Kinsta.
As part of our JS Development Team, you will be working with some of the most exciting JavaScript tools on the market to build our client-facing and internal tools.
Our stack:
#typescript #React, #nodejs #GraphQL, #SQL, #NoSQL, #Webpack, #Babel, #SWC, #Jest, #Storybook, #GitHub, #Docker, #Stripe
Check the job opening here: https://jobs.lever.co/kinsta/02849da6-5a65-4556-ba66-74e32c16f742?lever-via=44eKAsVAXN
JavaScript-Testing-Framework Jest landet bei der OpenJS Foundation
I am writing a few pure #javascript client functions and incredibly I'm enjoying it 💪 🤣
Working with #jest and pure functions is really a completely different world than piling some code frontend code