Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages/graphql-types-generator/fixtures/angular.ts
packages/graphql-types-generator/fixtures/output.ts
8 changes: 4 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ module.exports = {
'object-shorthand': 'off',
'prefer-const': 'off',
'prefer-template': 'off',
'@typescript-eslint/no-empty-function': 'off',
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': ['error', { allow: ['constructors'] }],
'@typescript-eslint/no-this-alias': 'off',
'import/named': 'off',
'import/newline-after-import': 'off',
Expand Down Expand Up @@ -130,7 +131,6 @@ module.exports = {
'no-use-before-define': 'off', // https://eslint.org/docs/rules/no-use-before-define
'prefer-destructuring': 'off', // https://eslint.org/docs/rules/prefer-destructuring
'prefer-object-spread': 'off', // https://eslint.org/docs/rules/prefer-object-spread
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-use-before-define': 'off',
Expand Down Expand Up @@ -187,7 +187,6 @@ module.exports = {
'default-case': 'off',
'no-return-assign': 'off',
'import/no-duplicates': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'no-throw-literal': 'off',
'react/static-property-placement': 'off',
'import/no-extraneous-dependencies': ['error', {devDependencies: true}],
Expand Down Expand Up @@ -228,7 +227,7 @@ module.exports = {
overrides: [
{
// edit rules here to modify test linting
files: ['__tests__/**', '*.test.ts', '*.test.js'],
files: ['**/__tests__/**', '**/test/**', '**/*.test.ts', '**/*.test.js'],
plugins: ['jest'],
extends: ['plugin:jest/recommended'],
rules: {
Expand All @@ -246,6 +245,7 @@ module.exports = {
'jest/no-identical-title': 'warn',
'no-useless-computed-key': 'warn',
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/no-empty-function': 'off',
'guard-for-in': 'warn',
},
},
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@
"@types/cli-progress": "3.11.0",
"@types/fs-extra": "^8.0.1",
"@types/glob": "^7.2.0",
"@types/jest": "^27.0.0",
"@types/jest": "^29.5.12",
"@types/js-yaml": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^4.0.0",
"@typescript-eslint/parser": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"amplify-headless-interface": "^1.13.1",
"@aws-sdk/client-codebuild": "^3.996.0",
"@aws-sdk/client-s3": "^3.996.0",
Expand All @@ -116,17 +116,17 @@
"globby": "^11.1.0",
"graphql-transformer-core": "^8.0.0",
"husky": "^4.0.0",
"jest": "^27.0.0",
"jest-circus": "^27.0.0",
"jest-junit": "^12.0.0",
"jest": "^29.7.0",
"jest-circus": "^29.7.0",
"jest-junit": "^16.0.0",
"js-yaml": "^4.0.0",
"lnk": "1.1.0",
"prettier": "^1.19.1",
"pretty-quick": "^4.0.0",
"rimraf": "^3.0.0",
"ts-jest": "^27.0.0",
"ts-node": "^8.10.1",
"typescript": "4.7.4"
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "5.2.2"
},
"resolutions": {
"**/@aws-amplify/amplify-codegen-e2e-tests/**/cookie": "^0.7.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/amplify-codegen-e2e-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"fs-extra": "^8.1.0",
"globby": "^11.1.0",
"ini": "^3.0.1",
"jest-circus": "^27.5.1",
"jest-environment-node": "^26.6.2",
"jest-circus": "^29.7.0",
"jest-environment-node": "^29.7.0",
"lodash": "^4.17.19",
"node-pty": "1.1.0",
"retimer": "2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/amplify-codegen-e2e-core/src/utils/nexpect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ function chain(context: Context): ExecutionContext {
return chain(context);
},

wait: function (expectation: string | RegExp, callback = (data: string) => {}): ExecutionContext {
wait: function (expectation: string | RegExp, callback?: (data: string) => void): ExecutionContext {
let _wait: ExecutionStep = {
fn: (data) => {
let val = testExpectation(data, expectation, context);
if (val === true && typeof callback === 'function') {
if (val === true && callback) {
callback(data);
}
return val;
Expand Down
20 changes: 12 additions & 8 deletions packages/amplify-codegen-e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
},
"devDependencies": {
"@aws-amplify/backend": "^1.0.0",
"@types/jest": "^27.0.0",
"@types/jest": "^29.5.12",
"graphql": "^15.8.0",
"ts-node": "^8.10.1"
"ts-node": "^10.9.2"
},
"peerDependencies": {
"@aws-amplify/amplify-cli-core": "^4.4.1",
Expand All @@ -67,9 +67,16 @@
"testRunner": "@aws-amplify/amplify-codegen-e2e-core/runner",
"testEnvironment": "@aws-amplify/amplify-codegen-e2e-core/environment",
"transform": {
"^.+\\.tsx?$": "ts-jest"
"^.+\\.tsx?$": [
"ts-jest",
{
"diagnostics": false
}
]
},
"testEnvironmentOptions": {
"url": "http://localhost"
},
"testURL": "http://localhost",
"testRegex": "(src/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"testPathIgnorePatterns": [
"/node_modules/",
Expand Down Expand Up @@ -106,10 +113,7 @@
"<rootDir>/src/setup-tests.ts"
],
"globals": {
"window": {},
"ts-jest": {
"diagnostics": false
}
"window": {}
}
},
"jest-junit": {
Expand Down
11 changes: 4 additions & 7 deletions packages/amplify-codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"aws"
],
"scripts": {
"test": "jest",
"test": "jest --coverage --coverageReporters=clover --coverageReporters=text",
"test-watch": "jest --watch",
"extract-api": "ts-node ../../scripts/extract-api.ts"
},
Expand Down Expand Up @@ -44,19 +44,16 @@
"graphql-transformer-core": "^8.0.0"
},
"jest": {
"collectCoverage": true,
"coverageThreshold": {
"global": {
"branches": 54,
"functions": 64,
"lines": 72
}
},
"coverageReporters": [
"clover",
"text"
],
"testURL": "http://localhost",
"testEnvironmentOptions": {
"url": "http://localhost"
},
"testRegex": "((\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`command - add without init should download introspection schema when api id 1`] = `
Object {
"amplifyExtension": Object {
{
"amplifyExtension": {
"apiId": "MOCK_API_ID",
"codeGenTarget": "TYPE_SCRIPT_OR_FLOW_OR_ANY_OTHER_LANGUAGE",
"docsFilePath": "MOCK_DOCS_FILE_PATH",
Expand All @@ -11,7 +11,7 @@ Object {
"generatedFileName": "API.TS",
"region": "us-east-1",
},
"excludes": Array [
"excludes": [
"MOCK_EXCLUDE",
"API.TS",
],
Expand All @@ -22,8 +22,8 @@ Object {
`;

exports[`command - add without init should read frontend and framework from options 1`] = `
Object {
"amplifyExtension": Object {
{
"amplifyExtension": {
"apiId": "MOCK_API_ID",
"codeGenTarget": "TYPE_SCRIPT_OR_FLOW_OR_ANY_OTHER_LANGUAGE",
"docsFilePath": "MOCK_DOCS_FILE_PATH",
Expand All @@ -32,7 +32,7 @@ Object {
"generatedFileName": "API.TS",
"region": "us-east-1",
},
"excludes": Array [
"excludes": [
"MOCK_EXCLUDE",
"API.TS",
],
Expand All @@ -43,8 +43,8 @@ Object {
`;

exports[`command - add without init should use existing schema if no api id 1`] = `
Object {
"amplifyExtension": Object {
{
"amplifyExtension": {
"apiId": null,
"codeGenTarget": "TYPE_SCRIPT_OR_FLOW_OR_ANY_OTHER_LANGUAGE",
"docsFilePath": "MOCK_DOCS_FILE_PATH",
Expand All @@ -53,7 +53,7 @@ Object {
"generatedFileName": "API.TS",
"region": "us-east-1",
},
"excludes": Array [
"excludes": [
"MOCK_EXCLUDE",
"API.TS",
],
Expand All @@ -64,8 +64,8 @@ Object {
`;

exports[`command - add without init should use region supplied when without init 1`] = `
Object {
"amplifyExtension": Object {
{
"amplifyExtension": {
"apiId": "MOCK_API_ID",
"codeGenTarget": "TYPE_SCRIPT_OR_FLOW_OR_ANY_OTHER_LANGUAGE",
"docsFilePath": "MOCK_DOCS_FILE_PATH",
Expand All @@ -74,7 +74,7 @@ Object {
"generatedFileName": "API.TS",
"region": "us-west-2",
},
"excludes": Array [
"excludes": [
"MOCK_EXCLUDE",
"API.TS",
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`command-models-generates models in expected output path android: Should generate for frontend when backend is not initialized locally, and logs no warnings or errors 1`] = `
Array [
[
"AmplifyModelProvider.java",
"SimpleModel.java",
]
`;

exports[`command-models-generates models in expected output path android: Should generate models from a single schema file 1`] = `
Array [
[
"AmplifyModelProvider.java",
"SimpleModel.java",
]
`;

exports[`command-models-generates models in expected output path android: Should generate models from any subdirectory in schema folder 1`] = `
Array [
[
"AmplifyModelProvider.java",
"SimpleModel.java",
]
`;

exports[`command-models-generates models in expected output path flutter: Should generate for frontend when backend is not initialized locally, and logs no warnings or errors 1`] = `
Array [
[
"ModelProvider.dart",
"SimpleModel.dart",
]
`;

exports[`command-models-generates models in expected output path flutter: Should generate models from a single schema file 1`] = `
Array [
[
"ModelProvider.dart",
"SimpleModel.dart",
]
`;

exports[`command-models-generates models in expected output path flutter: Should generate models from any subdirectory in schema folder 1`] = `
Array [
[
"ModelProvider.dart",
"SimpleModel.dart",
]
`;

exports[`command-models-generates models in expected output path ios: Should generate for frontend when backend is not initialized locally, and logs no warnings or errors 1`] = `
Array [
[
"AmplifyModels.swift",
"SimpleModel+Schema.swift",
"SimpleModel.swift",
]
`;

exports[`command-models-generates models in expected output path ios: Should generate models from a single schema file 1`] = `
Array [
[
"AmplifyModels.swift",
"SimpleModel+Schema.swift",
"SimpleModel.swift",
]
`;

exports[`command-models-generates models in expected output path ios: Should generate models from any subdirectory in schema folder 1`] = `
Array [
[
"AmplifyModels.swift",
"SimpleModel+Schema.swift",
"SimpleModel.swift",
]
`;

exports[`command-models-generates models in expected output path javascript: Should generate for frontend when backend is not initialized locally, and logs no warnings or errors 1`] = `
Array [
[
"index.d.ts",
"index.js",
"schema.d.ts",
Expand All @@ -76,7 +76,7 @@ Array [
`;

exports[`command-models-generates models in expected output path javascript: Should generate models from a single schema file 1`] = `
Array [
[
"index.d.ts",
"index.js",
"schema.d.ts",
Expand All @@ -85,7 +85,7 @@ Array [
`;

exports[`command-models-generates models in expected output path javascript: Should generate models from any subdirectory in schema folder 1`] = `
Array [
[
"index.d.ts",
"index.js",
"schema.d.ts",
Expand All @@ -94,7 +94,7 @@ Array [
`;

exports[`command-models-generates models in expected output path should use default directive definitions if getTransformerDirectives fails 1`] = `
Array [
[
"index.d.ts",
"index.js",
"schema.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-codegen/tests/commands/models.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ describe('command-models-generates models in expected output path', () => {

await expect(() => generateModels(MOCK_CONTEXT, { overrideOutputDir }))
.rejects
.toThrowErrorMatchingInlineSnapshot('"Unexpected --target value clojure provided, expected one of [\\"android\\",\\"ios\\",\\"flutter\\",\\"javascript\\",\\"typescript\\",\\"introspection\\"]"');
.toThrowErrorMatchingInlineSnapshot('"Unexpected --target value clojure provided, expected one of ["android","ios","flutter","javascript","typescript","introspection"]"');
});

it('throws an understandable error on missing model-schema flag and uninitialized backend', async () => {
Expand Down
Loading