Skip to content

Commit

Permalink
test(strapi): Added e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TriPSs committed Nov 20, 2023
1 parent b8352d0 commit d4c3c18
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
31 changes: 15 additions & 16 deletions e2e/strapi-e2e/tests/strapi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,32 @@ import {
import { ensureNxProject } from '../../utils/workspace'

describe('(e2e) strapi', () => {
beforeAll(() => {
ensureNxProject([
'@nx-extend/core:dist/packages/core',
'@nx-extend/strapi:dist/packages/strapi'
])
})
beforeAll(() => ensureNxProject([
'@nx-extend/core:dist/packages/core',
'@nx-extend/strapi:dist/packages/strapi'
]))

const appName = 'test-strapi'

it('should be able to generate', async () => {
await runNxCommandAsync(`generate @nx-extend/strapi:init ${appName}`)

expect(() => checkFilesExist(
`${appName}/src/main.ts`
`${appName}/src/index.ts`
)).not.toThrow()
}, 300000)

it('should be able to build a function', async () => {
await runNxCommandAsync(`build ${appName}`)

// TODO
}, 300000)

it('should be able to build a function and generate lock file', async () => {
it('should be able to build', async () => {
rmDist()
await runNxCommandAsync(`build ${appName} --prod`)
await runNxCommandAsync(`build ${appName}`)

// TODO
expect(() => checkFilesExist(
`dist/${appName}/package.json`,
`dist/${appName}/config/admin.js`,
`dist/${appName}/config/api.js`,
`dist/${appName}/config/database.js`,
`dist/${appName}/src/index.js`,
`dist/${appName}/build/index.html`
)).not.toThrow()
}, 300000)
})
10 changes: 8 additions & 2 deletions e2e/utils/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ export function ensureNxProject(patchPlugins: string[] = []): void {
stdio: 'inherit',
env: process.env
})
execSync('yarn', {

execSync('yarn set version berry', {
cwd: tmpProjectPath,
stdio: 'inherit',
env: process.env
})
}

execSync('yarn install', {
cwd: tmpProjectPath,
stdio: 'inherit',
env: process.env
})
}
2 changes: 1 addition & 1 deletion packages/strapi/src/generators/init/init.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function generateStrapi(options: NormalizedSchema) {
// use package.json version as strapiVersion (all packages have the same version);
strapiVersion: packageJson.dependencies['@strapi/strapi'],
debug: false,
quick: false,
quick: true,
packageJsonStrapi: {
template: undefined,
starter: undefined
Expand Down

0 comments on commit d4c3c18

Please sign in to comment.