-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
1,706 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = { | ||
displayName: 'vite-e2e', | ||
preset: '../../jest.preset.js', | ||
globals: { | ||
'ts-jest': { | ||
tsconfig: '<rootDir>/tsconfig.spec.json', | ||
}, | ||
}, | ||
transform: { | ||
'^.+\\.[tj]s$': 'ts-jest', | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
coverageDirectory: '../../coverage/apps/vite-e2e', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { tags } from '@angular-devkit/core'; | ||
import { | ||
checkFilesExist, | ||
ensureNxProject, | ||
runNxCommandAsync, | ||
uniq, | ||
updateFile, | ||
} from '@nrwl/nx-plugin/testing'; | ||
import { join } from 'path'; | ||
|
||
describe('vite e2e', () => { | ||
it('should create vite app', async () => { | ||
const appName = uniq('vite'); | ||
ensureNxProject('@nx-plus/vite', 'dist/libs/vite'); | ||
await runNxCommandAsync(`generate @nx-plus/vite:app ${appName}`); | ||
|
||
const lintResult = await runNxCommandAsync(`lint ${appName}`); | ||
expect(lintResult.stdout).toContain('All files pass linting.'); | ||
|
||
const testResult = await runNxCommandAsync(`test ${appName}`); | ||
expect(testResult.stderr).toContain(tags.stripIndent` | ||
Test Suites: 1 passed, 1 total | ||
Tests: 1 passed, 1 total | ||
Snapshots: 0 total | ||
`); | ||
|
||
disableHashing(appName); | ||
const buildResult = await runNxCommandAsync(`build ${appName}`); | ||
checkFilesExist( | ||
`dist/apps/${appName}/index.html`, | ||
`dist/apps/${appName}/assets/index.css`, | ||
`dist/apps/${appName}/assets/index.js`, | ||
`dist/apps/${appName}/assets/vendor.js` | ||
); | ||
// Cannot disable hashing for assets | ||
// see: https://github.com/vitejs/vite/issues/2944 | ||
expect(buildResult.stdout).toContain(`dist/apps/${appName}/assets/logo`); | ||
|
||
const e2eResult = await runNxCommandAsync(`e2e ${appName}-e2e --headless`); | ||
expect(e2eResult.stdout).toContain('All specs passed!'); | ||
}, 100000); | ||
}); | ||
|
||
function disableHashing(app: string, directory: string = '') { | ||
updateFile(join('apps', app, directory, 'vite.config.ts'), (content) => | ||
content.replace( | ||
'emptyOutDir: true,', | ||
`emptyOutDir: true, | ||
rollupOptions: { | ||
output: { | ||
entryFileNames: \`assets/[name].js\`, | ||
chunkFileNames: \`assets/[name].js\`, | ||
assetFileNames: \`assets/[name].[ext]\` | ||
} | ||
}` | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"module": "commonjs", | ||
"types": ["jest", "node"] | ||
}, | ||
"include": ["**/*.spec.ts", "**/*.d.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": [["@nrwl/web/babel", { "useBuiltIns": "usage" }]] | ||
} |
Oops, something went wrong.