Comments (10)
👋
I need a little more information if you don't mind.
- How are you trying to run it from the root directory?
- Why is the project setup this way?
An example repo would help me a lot in understanding what's going on and potentially fixing it.
from svelte-jester.
By coincidence, I ran into the same issue today. In my case, I had set up a monorepo and was using the Jest projects option to run tests across multiple packages from the root. Sub-packages had their own svelte.config.js
, but svelte-jester
was failing as it was looking for the svelte.config.js
file in the project root only.
Babel handles this by providing the { rootMode: 'upward' }
option, which walks up directories until it finds a babel.config.json
. A proposed solution is to add a { rootMode: 'upward' }
option that walks up from the directory of the current file being transformed until it finds the first svelte.config.js
file.
I have an incoming PR for this.
from svelte-jester.
Released in 1.1.0
, thanks @tom-fletcher and I hope that solves your issues @jamesopstad.
from svelte-jester.
Thanks both for working on this. Unfortunately it's currently broken because the svelteconfig.js
file is not included in the release. I think it needs to be added to the files entry in the package.json
.
from svelte-jester.
Absolutely right @jamesopstad, svelteconfig.js
needs to be in the package.json
files pattern for the npm release 😶
@mihar-22 Can we get #14 merged and a release out asap?
from svelte-jester.
Released and fixed in 1.1.1
, sorry for missing that guys.
from svelte-jester.
@mihar-22 Thanks, and I was kicking myself when I realised!
@jamesopstad Hopefully this will now allow you run tests from the project root with config files in child folders
Additional monorepo use case
Description
The current implementation stops searching for svelte.config.js
when it reaches the cwd. This resolves the issue above when tests are being run from the project root as this is the cwd, however I have found another use case for monorepos:
- The user wants to have one
svelte.config.js
in the project root folder and does not want to duplicate this in each of their workspaces - Currently, this would work when
{ rootMode: 'upward' }
is set and tests are run from the project root, but would not work when running tests directly from workspace folders - The user would have to re-import the root
svelte.config.js
file into individualsvelte.config.js
files in each of the workspaces. This creates redundant config files
Resolution
- This use case can be covered when the
{ rootMode: 'upward' }
option is set by continuing to walk upward from the cwd until it finds asvelte.config.js
(or throw an error at the filesystem root) - By default (
rootMode
is not set toupward
)svelte.config.js
should only be resolved from the project root, and throw an error if not found. This avoids the risk of walking up the directory structure and finding a forgottensvelte.config.js
in the home directory, which could cause unexpected errors
I will have a look at this today...
from svelte-jester.
Hm ye I see that being a pain. Maybe a separate option? I think 'upward'
can walk up to the root and maybe something like 'cwd'
can walk up to the current working directory?
from svelte-jester.
As far as I am aware there isn't any easy way to determine the worktree root of a yarn workspace when you are executing from within it, so the only option is to keep walking up the filesystem. However, this would only be an issue if:
- The user has set the
upward
option and - The user forgets to put a
svelte.config.js
in their workspace project or the worktree root above it and - The user has a random
svelte.config.js
file sitting somewhere above their project directory
Note that it stops at the first config file it finds, so it would only go out of the project directory if there weren't any config files above the svelte file being transformed.
I've got a working version that handles both the original and new use cases with just the upward
command, and leaves the default to look for the file in the cwd
(which doesn't do any walking at all)
from svelte-jester.
I'm using the latest 1.1.2
release and can confirm this resolves the issue. Many thanks.
from svelte-jester.
Related Issues (20)
- Add presets like vue-jest
- Svelte 4 support HOT 7
- Add mechanism to call beforeEach() and afterEach() manually inside an it block HOT 1
- Allow to use CJS with Svelte 4 without throwing an error HOT 3
- Call `compileModule` for `.svelte.js` files in Svelte 5 HOT 8
- Phantom file listed in coverage HOT 2
- Transformer.js must export a "process" function - jester v2.0.1 jest 27 HOT 33
- Support components mocks HOT 2
- yarn vs npm
- jestOptions?.transformerConfig Unexpected token '.' HOT 2
- TypeError [ERR_INVALID_ARG_TYPE] HOT 16
- Regression in 2.1.2: a transform must export a `process` or `processAsync` function. HOT 9
- Cannot find module './preprocess.js' HOT 13
- TypeError [ERR_INVALID_ARG_TYPE] - Sapper HOT 2
- Cannot import from context="module" HOT 10
- Image imports that use typescript alias returns undefined HOT 1
- ParseError: Colon is expected (svelte with scss style) HOT 1
- Coverage of untested files not collected HOT 8
- Completely fails when using preprocessing HOT 4
- <svelte:component/> breaks rendering with `TypeError: switch_value is not a constructor` HOT 1
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 svelte-jester.