Skip to content

Commit

Permalink
chore(vue): migrate to standardized tsconfig and align exports test (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
calebpollman authored Jan 30, 2024
1 parent 726ac98 commit a82bc69
Show file tree
Hide file tree
Showing 24 changed files with 48 additions and 57 deletions.
5 changes: 5 additions & 0 deletions .changeset/odd-terms-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@aws-amplify/ui-vue": minor
---

chore(vue): migrate to standardized tsconfig and align exports test
10 changes: 10 additions & 0 deletions packages/configs/typescript/tsconfig.vue.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
// required in `vue` projects
"jsx": "preserve",
// see: https://github.com/vuejs/test-utils/issues/1538
"skipLibCheck": true,
"types": ["vite/client"]
}
}
1 change: 1 addition & 0 deletions packages/vue/__mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
5 changes: 3 additions & 2 deletions packages/vue/__tests__/exports.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as exported from '../dist';
import * as exported from '../src';

describe('@aws-amplify/ui-vue', () => {
describe('exports', () => {
it('should match snapshot', () => {
expect(Object.keys(exported)).toMatchSnapshot();
const sortedExports = Object.keys(exported).sort();
expect(sortedExports).toMatchSnapshot();
});
});
});
3 changes: 0 additions & 3 deletions packages/vue/index.js

This file was deleted.

7 changes: 5 additions & 2 deletions packages/vue/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ const config: Config = {
},
testEnvironment: 'jsdom',
verbose: true,
moduleFileExtensions: ['js', 'ts', 'json', 'vue', 'tsx'],
moduleNameMapper: { '^nanoid$': '<rootDir>/../../node_modules/nanoid' },
moduleFileExtensions: ['js', 'ts', 'vue'],
moduleNameMapper: {
'\\.css$': '<rootDir>/__mocks__/styleMock.js',
'^nanoid$': '<rootDir>/../../node_modules/nanoid',
},
modulePathIgnorePatterns: ['<rootDir>/dist/'],
setupFilesAfterEnv: ['./jest.setup.ts'],
transform: {
Expand Down
1 change: 0 additions & 1 deletion packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
},
"dependencies": {
"@aws-amplify/ui": "6.0.8",
"@vue/tsconfig": "^0.1.3",
"@vueuse/core": "7.5.5",
"@xstate/vue": "0.8.1",
"nanoid": "3.1.31",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@aws-amplify/ui';

import { components } from '../../../global-spec';
import { baseMockServiceFacade } from '../../composables/__mock__/useAuthenticatorMock';
import { baseMockServiceFacade } from '../../composables/__mocks__/useAuthenticatorMock';
import * as UseAuthComposables from '../../composables/useAuth';
import Authenticator from '../authenticator';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AuthInterpreter, AuthMachineState } from '@aws-amplify/ui';

import { components } from '../../../global-spec';
import * as UseAuthComposables from '../../composables/useAuth';
import { baseMockServiceFacade } from '../../composables/__mock__/useAuthenticatorMock';
import { baseMockServiceFacade } from '../../composables/__mocks__/useAuthenticatorMock';
import { UseAuthenticator } from '../../types';
import ConfirmResetPassword from '../confirm-reset-password.vue';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AuthInterpreter, AuthMachineState } from '@aws-amplify/ui';

import { components } from '../../../global-spec';
import * as UseAuthComposables from '../../composables/useAuth';
import { baseMockServiceFacade } from '../../composables/__mock__/useAuthenticatorMock';
import { baseMockServiceFacade } from '../../composables/__mocks__/useAuthenticatorMock';
import { UseAuthenticator } from '../../types';
import ConfirmSignIn from '../confirm-sign-in.vue';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {

import { components } from '../../../global-spec';
import * as UseAuthComposables from '../../composables/useAuth';
import { baseMockServiceFacade } from '../../composables/__mock__/useAuthenticatorMock';
import { baseMockServiceFacade } from '../../composables/__mocks__/useAuthenticatorMock';
import ConfirmSignUp from '../confirm-sign-up.vue';

jest.spyOn(UseAuthComposables, 'useAuth').mockReturnValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {

import { components } from '../../../global-spec';
import * as UseAuthComposables from '../../composables/useAuth';
import { baseMockServiceFacade } from '../../composables/__mock__/useAuthenticatorMock';
import { baseMockServiceFacade } from '../../composables/__mocks__/useAuthenticatorMock';
import ConfirmVerifyUser from '../confirm-verify-user.vue';

jest.spyOn(UseAuthComposables, 'useAuth').mockReturnValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { reactive } from 'vue';
import { screen, render, fireEvent } from '@testing-library/vue';

import { components } from '../../../global-spec';
import { baseMockServiceFacade } from '../../composables/__mock__/useAuthenticatorMock';
import { baseMockServiceFacade } from '../../composables/__mocks__/useAuthenticatorMock';
import * as UseAuthComposables from '../../composables/useAuth';
import FederatedSignInButton from '../federated-sign-in-button.vue';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { reactive, ref, Ref } from 'vue';
import { render, screen } from '@testing-library/vue';

import { components } from '../../../global-spec';
import { baseMockServiceFacade } from '../../composables/__mock__/useAuthenticatorMock';
import { baseMockServiceFacade } from '../../composables/__mocks__/useAuthenticatorMock';
import * as UseAuthComposables from '../../composables/useAuth';
import FederatedSignIn from '../federated-sign-in.vue';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AuthInterpreter, AuthMachineState } from '@aws-amplify/ui';

import { components } from '../../../global-spec';
import * as UseAuthComposables from '../../composables/useAuth';
import { baseMockServiceFacade } from '../../composables/__mock__/useAuthenticatorMock';
import { baseMockServiceFacade } from '../../composables/__mocks__/useAuthenticatorMock';
import { UseAuthenticator } from '../../types';
import ForceNewPassword from '../force-new-password.vue';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AuthInterpreter, AuthMachineState } from '@aws-amplify/ui';

import { components } from '../../../global-spec';
import * as UseAuthComposables from '../../composables/useAuth';
import { baseMockServiceFacade } from '../../composables/__mock__/useAuthenticatorMock';
import { baseMockServiceFacade } from '../../composables/__mocks__/useAuthenticatorMock';
import { UseAuthenticator } from '../../types';
import ForgotPassword from '../forgot-password.vue';

Expand Down
2 changes: 1 addition & 1 deletion packages/vue/src/components/__tests__/setup-totp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as UIModule from '@aws-amplify/ui';

import { components } from '../../../global-spec';
import * as UseAuthComposables from '../../composables/useAuth';
import { baseMockServiceFacade } from '../../composables/__mock__/useAuthenticatorMock';
import { baseMockServiceFacade } from '../../composables/__mocks__/useAuthenticatorMock';
import { UseAuthenticator } from '../../types';
import SetupTotp from '../setup-totp.vue';

Expand Down
2 changes: 1 addition & 1 deletion packages/vue/src/components/__tests__/sign-in.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AuthInterpreter, AuthMachineState } from '@aws-amplify/ui';

import { components } from '../../../global-spec';
import * as UseAuthComposables from '../../composables/useAuth';
import { baseMockServiceFacade } from '../../composables/__mock__/useAuthenticatorMock';
import { baseMockServiceFacade } from '../../composables/__mocks__/useAuthenticatorMock';
import SignIn from '../sign-in.vue';

jest.spyOn(UseAuthComposables, 'useAuth').mockReturnValue({
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/src/components/__tests__/sign-up.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {

import { components } from '../../../global-spec';
import * as UseAuthComposables from '../../composables/useAuth';
import { baseMockServiceFacade } from '../../composables/__mock__/useAuthenticatorMock';
import { baseMockServiceFacade } from '../../composables/__mocks__/useAuthenticatorMock';
import SignUp from '../sign-up.vue';

jest.spyOn(UseAuthComposables, 'useAuth').mockReturnValue({
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/src/components/__tests__/verify-user.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {

import { components } from '../../../global-spec';
import * as UseAuthComposables from '../../composables/useAuth';
import { baseMockServiceFacade } from '../../composables/__mock__/useAuthenticatorMock';
import { baseMockServiceFacade } from '../../composables/__mocks__/useAuthenticatorMock';
import VerifyUser from '../verify-user.vue';

jest.spyOn(UseAuthComposables, 'useAuth').mockReturnValue({
Expand Down
28 changes: 9 additions & 19 deletions packages/vue/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
// see: https://github.com/vuejs/test-utils/issues/1538
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"allowJs": true,
"sourceMap": true,
"baseUrl": ".",
"outDir": "dist",
"resolveJsonModule": true,
"types": ["webpack-env", "vite/client"]
},
"include": ["jest.setup.ts", "src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
"extends": "@aws-amplify/typescript-config/tsconfig.vue.json",
"include": [
"__mocks__",
"__tests__",
"*.ts",
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue"
],
"exclude": ["node_modules"]
}
14 changes: 2 additions & 12 deletions packages/vue/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ export default defineConfig({
declaration: true,
declarationMap: true,
},
exclude: [
'vite.config.ts',
'*.ts',
'__tests__',
'**/__mock__',
'**/__tests__',
],
exclude: ['*.ts', '**/__mocks__', '**/__tests__'],
},
}) as PluginOption,
],
Expand Down Expand Up @@ -64,11 +58,7 @@ export default defineConfig({
'aws-amplify/utils',
'vue',
],
output: {
globals: {
vue: 'Vue',
},
},
output: { globals: { vue: 'Vue' } },
},
},
});
5 changes: 0 additions & 5 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a82bc69

Please sign in to comment.