You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote Playwright tests for my web app that uses django-vite. Currently, I have to run manage.py collectstatic every time I want to run my tests (if the frontend changed).
Django has a special tool for this use case - StaticLiveServerTestCase. It serves the static files right from STATICFILES_DIRS, allowing me to just run the tests without doing manage.py collectstatic.
When I'm running the tests, they are failing with a django-vite error:
Cannot find src/main.jsx in Vite manifest at /code/static/manifest.json
It looks like the error is originating here. I checked with a debugger, and self._manifest was None.
It would be cool to be able to use this Django feature with django-vite. How can I help to resolve/investigate the issue?
The text was updated successfully, but these errors were encountered:
During your playwright test execution, you'll want to adjust your DJANGO_VITE_MANIFEST_PATH and DJANGO_VITE_STATIC_URL_PREFIX.
By default, with DEV_MODE=False, django-vite will expect to look for your manifest.json in your STATIC_ROOT, which I'm guessing you've set to /code/static/. But your manifest.json won't be there if haven't run collectstatic.
So you're going to need to set your DJANGO_VITE_MANIFEST_PATH to the location in STATICFILES_DIR where your compiled vite assets initially lived before then get collected into your STATIC_ROOT. See if that solves your self._manifest being set to None. That's step 1.
Step 2 will be probably be the problem of your individual vite_assets not being discovered since they're not in STATIC_ROOT either. manifest.json gives the related paths of each of your vite_asset entries, but since they aren't in your STATIC_ROOT, the vite_asset tag may not know where they live.
If your assets don't get loaded after you've fixed your manifest_path, then you need to adjust DJANGO_VITE_STATIC_URL_PREFIX to point to the same root directory as your DJANGO_VITE_MANIFEST_PATH -- the place they live in STATICFILES_DIR before they get collected.
I wrote Playwright tests for my web app that uses django-vite. Currently, I have to run
manage.py collectstatic
every time I want to run my tests (if the frontend changed).Django has a special tool for this use case - StaticLiveServerTestCase. It serves the static files right from
STATICFILES_DIRS
, allowing me to just run the tests without doingmanage.py collectstatic
.When I'm running the tests, they are failing with a django-vite error:
It looks like the error is originating here. I checked with a debugger, and
self._manifest
wasNone
.It would be cool to be able to use this Django feature with django-vite. How can I help to resolve/investigate the issue?
The text was updated successfully, but these errors were encountered: