Comments (7)
What are the actual suites (files) named? Can you share an example of your full path?
This should work for the following:
/tests/something.spec.tsx
/tests/folder/something.spec.tsx
- either of the above with "test" instead of "spec" in the name
- either of the above for JSX files
- either of the above with additional nested folders
from jest-preset-spfx-react16.
yes, so an actual example file is:
/tests/common/services/UpgradeServices.spec.ts
The provided jest-preset.json file specifies the following
"testMatch": [ "**/src/**/*.(spec|test).+(ts|js)?(x)", "**/__tests__/**/*.(spec|test).+(ts|js)?(x)" ],
That setup will not find my above file on windows. However, if I adjust it to the following it works fine:
"testMatch": [ "**/src/**/*.(spec|test).+(ts|js)?(x)", "**/tests/**/*.(spec|test).+(ts|js)?(x)", "**/__tests__/**/*.(spec|test).+(ts|js)?(x)" ],
I was basically trying to verify that my assumption that __tests__
was indeed a pattern that should match the root folder tests as a sibling of src. What I'm wondering is if this is a limitation of mac vs windows.
from jest-preset-spfx-react16.
It's not finding it because your folder is named tests
, not __tests__
from jest-preset-spfx-react16.
Actually, I tried that first, thinking it was literal and not a pattern and that doesn't work. I just retested it again to make sure, also copied the value __tests__
to make sure there is no encoding problem as I've had that bite me with PowerShell.
To to be clear this path also doesn't work:
__tests__/common/services/UpgradeServices.spec.ts
from jest-preset-spfx-react16.
My current workaround, that's good for anyone else to know in case they have a requirement that their tests be in some folder way outside the patterns you support, is to add an entry into the jest.config.json file in the config folder... so this:
{
"preset": "@voitanos/jest-preset-spfx-react16",
"rootDir": "../tests",
"testMatch": [
"**/tests/**/*.(spec|test).+(ts|js)?(x)"
]
}
from jest-preset-spfx-react16.
_
isn't a special character in regex... just a string.
Most developers when writing tests put them either beside the code they test (ie: src
) or in a __tests__
folder as that pattern matches the folders generated by snapshots when doing React component rendering tests.
If you want to have your tests in a folder separate from your source, just override the testMatch property defined in the preset. If you wanted it to be either "src" or "tests", set the contents of jest.config.json to:
{
"preset": "@voitanos/jest-preset-spfx-react16",
"rootDir": "../tests",
"testMatch": [
"**/(src|tests)/**/*.(spec|test).+(ts|js)?(x)"
]
}
from jest-preset-spfx-react16.
Yep, well... for whatever reason I can't use the folder __tests__
so... it's what it is... and I had applied the workaround... thanks for the confirmation.
from jest-preset-spfx-react16.
Related Issues (11)
- Unexpected token export when running npm test HOT 7
- V1.3.1 causes different TSC rules to be applied than project settings HOT 2
- Unit testing typescript SPFx web part using jest
- NPM postinstall error @voitanos/[email protected] HOT 5
- Problem when using WebPartTitle component HOT 4
- Gracefully handle failures in postinstall step
- Add automated tests
- Add continuous deployment
- Unable to use with ES6 modules HOT 30
- undefined class names HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jest-preset-spfx-react16.