← Back to Discord Forum

spect.ts VS test.ts

Sorry if this question has been asked before.

Is there a difference between spec.ts files and test.ts files? I read online it is a personal preference? Not 100% if this is the case?

This thread is trying to answer question "Is there a difference between spec.ts files and test.ts files?"

4 replies

Personal preference, and in many places required best practice. But the hard answer is no, you don't hae to use .spec.ts

It does however, allow you to more easily isolate or find files in your config if all test files have a common suffix

// Other Jest configuration options...
  testRegex: '\\.(test|spec)\\.ts$', // Recognize files with .test.ts or .spec.ts extension

@datdaxx thank you for the information. When you say β€œin many places required best practice.” Are you referring to spec.ts files are required and best practice?

@afonte: in many places meaning at many companies / teams

in many places meaning at many companies / teams

I love how so many convey "personal preference" as best practice on any issue, all the while there often is not standard... My personal choice would be to follow the convention that are in the docs. Something about when in Rome, do as... Being around as long as i have programming it seems most often the "Best Practices" change every 2 or 3 years 😁. I use to do a lot of "Business" programming working at banks, and we had set of rules to follow, a friend worked at Boeing and he had federally mandated standards he had to follow. Interesting so many points for "best practice" were different. Then another friend iworked as a games programming, ha! you guessed it, his "best practices" were again different from all of us... In the end would say "Best Practice" is defined where you work, that for me is the "Best Practice", as it will best help you to stay employed 😎 Then even though some "practices" are ridiculous say like no lines longer than 80 characters, another place was do what you think looks best to read the code... Which is better? Often seems more like a religious argument... The one thing i would push is to be consistent and all code follows the same style, and thus the coding standards doc, and this often changes where ever you work at...

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.