Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: The documented approach to testing doesn't work for a scaffolded typescript project #1828

Closed
Tracked by #1940
timbarclay opened this issue Aug 23, 2023 · 3 comments
Assignees
Labels
issue: docs/code example Issues about incorrect code examples found on docs.strapi.io

Comments

@timbarclay
Copy link

Link to the documentation page or resource

https://docs.strapi.io/dev-docs/testing

Describe the bug

If you generate a new Typescript-based Strapi project and then follow the instructions in the testing documentation, Strapi fails to start properly. This appears to be because all the config files are .ts files, whereas the code to load the configuration files requires them to have .js or .json extensions.

Additional context

No response

Suggested improvements or fixes

Add a section to the testing page mentioning what extra steps are required for typescript projects, which from what I've been able to work out is something like

const appContext = await Strapi.compile();
const instance = Strapi(appContext);
await instance.load();

Related issue(s)/PR(s)

No response

@gregg-cbs
Copy link

gregg-cbs commented Oct 16, 2023

Because of the documentation I am seeing errors like: "Unknown dialect undefined"
image

The example should be something like this or as suggested by @timbarclay

await Strapi({
  appDir: process.cwd(),
  distDir: process.cwd() + "/dist",
  autoReload: false,
  serveAdminPanel: false
}).load();

This documentation also says:
image
^okay... so then what do we do when the example only shows us how to use sqlite? Can we get examples on postgres?

@Boegie19
Copy link
Contributor

that means that in your env no database is set.

@pwizla pwizla self-assigned this Oct 18, 2023
@pwizla pwizla added the issue: docs/code example Issues about incorrect code examples found on docs.strapi.io label Oct 18, 2023
@pwizla pwizla mentioned this issue Dec 4, 2023
3 tasks
@pwizla
Copy link
Collaborator

pwizla commented Dec 4, 2023

Hi,
Thanks for reporting. I'm closing this issue, but it's included in the meta issue about reworking the Testing page (#1940).
In the meantime I'll check with Strapi engineers to see if they can come up with a solution.

@pwizla pwizla closed this as completed Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: docs/code example Issues about incorrect code examples found on docs.strapi.io
Projects
None yet
Development

No branches or pull requests

4 participants