{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":2430,"path":"application-development/servicenow-sdk/atf-test-now-ts.md","title":"Automated Test Framework Test API - ServiceNow Fluent","bundle":null,"doc_type":null,"release":"australia","body":"\n# Automated Test Framework Test API - ServiceNow Fluent\n\nThe Automated Test Framework Test API defines automated tests \\[sys\\_atf\\_test\\] that you can run to confirm that your instance works after making a change.\n\n**Note:** For the latest ServiceNow Fluent API documentation and examples, see the [ServiceNow Fluent API reference](https://servicenow.github.io/sdk/category/api-reference) and [ServiceNow SDK examples repository](https://github.com/ServiceNow/sdk-examples) on GitHub.\n\nFor general information about Automated Test Framework tests, see [Automated Test Framework \\(ATF\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/automated-test-framework-atf/atf-landing-page.md).\n\n**Parent Topic:**[ServiceNow Fluent API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/servicenow-sdk/servicenow-fluent-api-reference.md)\n\n**Related topics**  \n\n\n[ServiceNow Fluent](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/servicenow-fluent.md)\n\n## Test object\n\nCreate an automated test \\[sys\\_atf\\_test\\] containing a series of steps to execute.\n\n<table id=\"table_vy2_525_jq\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\n$id\n\n</td><td>\n\nString or Number\n\n</td><td>\n\nRequired. A unique ID for the metadata object. When you build the application, this ID is hashed into a unique sys\\_id. For more information, see [ServiceNow Fluent language constructs](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/servicenow-sdk/fluent-constructs.md).Format: `Now.ID['String' or Number]`\n\n</td></tr><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nA unique name for the test.\n\n</td></tr><tr><td>\n\ndescription\n\n</td><td>\n\nString\n\n</td><td>\n\nA description of what the test does.\n\n</td></tr><tr><td>\n\nactive\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the test is active.Valid values:\n\n-   true: The test is active.\n-   false: The test isn't active.\n\nDefault: true\n\n</td></tr><tr><td>\n\nfailOnServerError\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether to fail when a server error occurs during the test.Valid values:\n\n-   true: The test fails when a server error occurs.\n-   false: The test doesn't fail when a server error occurs.\n\nDefault: true\n\n</td></tr><tr><td>\n\nconfigurationFunction\n\n</td><td>\n\nFunction\n\n</td><td>\n\nThe steps of the test. Test steps are passed as statements within the atf function. For example:```javascript\n(atf) => {\n    atf.form.openNewForm({\n        table: 'sn_example_table',\n        formUI: 'standard_ui',\n        view: '',\n    })\n}\n```\n\nFor more information about test steps, see [Supported test steps](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/servicenow-sdk/atf-test-now-ts.md).\n\n</td></tr><tr><td>\n\n$meta\n\n</td><td>\n\nObject\n\n</td><td>\n\nMetadata for the application metadata.With the installMethod property, you can map the application metadata to an output directory that loads only in specific circumstances.\n\n```javascript\n$meta: {\n      installMethod: 'String'\n}\n```\n\nValid values for installMethod:\n\n-   demo: Outputs the application metadata to the `metadata/unload.demo` directory to be installed with the application when the **Load demo data** option is selected.\n-   first install: Outputs the application metadata to the `metadata/unload` directory to be installed only the first time an application is installed on an instance.\n\n</td></tr></tbody>\n</table>The output values of test steps with output variables can be saved as variables and used as inputs to other steps using the syntax `output.<output-variable>`. The output variables can be used both directly as inputs on appropriate fields or inside of a template string, such as with `atf.server.log` in the following example.\n\n```javascript\nimport { Test } from '@servicenow/sdk/core'\n\nTest({\n        active: true,\n        failOnServerError: true,\n        name: 'Simple example',\n        description: 'An illustrative test written in fluent',\n        $id: Now.ID[1],\n    },\n    (atf) => {\n        atf.form.openNewForm({\n            table: 'sn_table_app_reptile_table',\n            formUI: 'standard_ui',\n            view: '',\n        })\n        atf.form.setFieldValue({\n            table: 'sn_table_app_reptile_table',\n            formUI: 'standard_ui',\n            fieldValues: {\n                reptiles: 'lizard' as any,\n            },\n        })\n        const output = atf.form.submitForm({ assertType: 'form_submitted_to_server', formUI: 'standard_ui' })\n        atf.server.recordValidation({\n            recordId: output.record_id,\n            table: 'sn_table_app_reptile_table',\n            assertType: 'record_validated',\n            enforceSecurity: true,\n            fieldValues: 'reptiles=lizard',\n        })\n        atf.server.log({\n            log: `Submitted record with sys_id: ${output.record_id} to table ${output.table}`\n        })\n    }\n)\n```\n\n### Supported test steps\n\nThe following test steps are supported. For information about step properties, see the [Automated Test Framework \\(ATF\\) test step categories](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/automated-test-framework-atf/test-step-categories.md) documentation.\n\n**Note:** Some fields available for test steps on forms aren't available as properties in ServiceNow Fluent.\n\n<table id=\"table_uqw_2mp_ccc\"><thead><tr><th>\n\nCategory\n\n</th><th>\n\nSteps\n\n</th></tr></thead><tbody><tr><td>\n\n[Application Navigator category](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/automated-test-framework-atf/test-steps-app-navigator-category.md)\n\n</td><td>\n\n-   atf.applicationNavigator.applicationMenuVisibility\n-   atf.applicationNavigator.moduleVisibility\n-   atf.applicationNavigator.navigateToModule\n\n</td></tr><tr><td>\n\n[Email category](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/automated-test-framework-atf/test-steps-email-category.md)\n\n</td><td>\n\n-   atf.email.generateInboundEmail\n-   atf.email.generateInboundReplyEmail\n-   atf.email.generateRandomString\n-   atf.email.validateOutboundEmail\n-   atf.email.validateOutboundEmailGeneratedByFlow\n-   atf.email.validateOutboundEmailGeneratedByNotification\n\n</td></tr><tr><td>\n\n[Form category](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/automated-test-framework-atf/test-steps-form-category.md)\n\n</td><td>\n\n-   atf.form.addAttachmentsToForm\n-   atf.form.clickDeclarativeAction\n-   atf.form.clickModalButton\n-   atf.form.clickUIAction\n-   atf.form.declarativeActionVisibility\n-   atf.form.fieldStateValidation\n-   atf.form.fieldValueValidation\n-   atf.form.openExistingRecord\n-   atf.form.openNewForm\n-   atf.form.setFieldValue\n-   atf.form.submitForm\n-   atf.form.uiActionVisibility\n\n</td></tr><tr><td>\n\n[Forms in Service Portal category](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/automated-test-framework-atf/test-steps-forms-portal-category.md)\n\n</td><td>\n\n-   atf.form\\_SP.addAttachmentsToForm\n-   atf.form\\_SP.clickUIAction\\_SP\n-   atf.form\\_SP.fieldStateValidation\\_SP\n-   atf.form\\_SP.fieldValueValidation\\_SP\n-   atf.form\\_SP.openForm\\_SP\n-   atf.form\\_SP.openServicePortalPage\n-   atf.form\\_SP.setFieldValue\\_SP\n-   atf.form\\_SP.submitForm\\_SP\n-   atf.form\\_SP.uiActionVisibilityValidation\\_SP\n\n</td></tr><tr><td>\n\n[Quick start tests for Dashboards](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/now-intelligence/quick-start-tests-dashboards.md)\n\n</td><td>\n\n-   atf.reporting.responsiveDashboard\n-   atf.reporting.responsiveDashboardSharing\n\n</td></tr><tr><td>\n\n[REST category](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/automated-test-framework-atf/test-steps-rest-category.md)\n\n</td><td>\n\n-   atf.rest.assertJsonResponsePayloadElement\n-   atf.rest.assertResponseHeader\n-   atf.rest.assertResponseJSONPayloadIsValid\n-   atf.rest.assertResponsePayload\n-   atf.rest.assertResponseTime\n-   atf.rest.assertResponseXMLPayloadIsWellFormed\n-   atf.rest.assertStatusCode\n-   atf.rest.assertStatusCodeName\n-   atf.rest.assertXMLResponsePayloadElement\n-   atf.rest.sendRestRequest\n\n</td></tr><tr><td>\n\n[Server category](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/automated-test-framework-atf/test-steps-server-category.md)\n\n</td><td>\n\n-   atf.server.addAttachmentsToExistingRecord\n-   atf.server.checkoutShoppingCart\n-   atf.server.createUser\n-   atf.server.impersonate\n-   atf.server.log\n-   atf.server.recordDelete\n-   atf.server.recordInsert\n-   atf.server.recordQuery\n-   atf.server.recordUpdate\n-   atf.server.recordValidation\n-   atf.server.replayRequestItem\n-   atf.server.runServerSideScript\n-   atf.server.searchForCatalogItem\n-   atf.server.setOutputVariables\n\n</td></tr><tr><td>\n\n[Service Catalog category](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/automated-test-framework-atf/test-steps-service-catalog-category.md)\n\n</td><td>\n\n-   atf.catalog.addItemToShoppingCart\n-   atf.catalog.openCatalogItem\n-   atf.catalog.openRecordProducer\n-   atf.catalog.orderCatalogItem\n-   atf.catalog.setCatalogItemQuantity\n-   atf.catalog.setVariableValue\n-   atf.catalog.submitRecordProducer\n-   atf.catalog.validatePriceAndRecurringPrice\n-   atf.catalog.variableStateValidation\n-   atf.catalog.validateVariableValue\n\n</td></tr><tr><td>\n\n[Service Catalog in Service Portal category](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/automated-test-framework-atf/test-steps-catalog-portal-category.md)\n\n</td><td>\n\n-   atf.catalog\\_SP.addItemtoShoppingCart\\_SP\n-   atf.catalog\\_SP.addOrderGuidetoShoppingCart\\_SP\n-   atf.catalog\\_SP.addRowToMultiRowVariableSet\\_SP\n-   atf.catalog\\_SP.navigatewithinOrderGuide\\_SP\n-   atf.catalog\\_SP.openCatalogItem\\_SP\n-   atf.catalog\\_SP.openOrderGuide\\_SP\n-   atf.catalog\\_SP.openRecordProducer\\_SP\n-   atf.catalog\\_SP.orderCatalogItem\\_SP\n-   atf.catalog\\_SP.reviewIteminOrderGuide\\_SP\n-   atf.catalog\\_SP.reviewOrderGuideSummary\\_SP\n-   atf.catalog\\_SP.saveCurrentRowOfMultiRowVariableSet\\_SP\n-   atf.catalog\\_SP.setCatalogItemQuantity\\_SP\n-   atf.catalog\\_SP.setVariableValue\\_SP\n-   atf.catalog\\_SP.submitOrderGuide\\_SP\n-   atf.catalog\\_SP.submitRecordProducer\\_SP\n-   atf.catalog\\_SP.validateOrderGuideItem\\_SP\n-   atf.catalog\\_SP.validatePriceAndRecurringPrice\\_SP\n-   atf.catalog\\_SP.variableStateValidation\\_SP\n-   atf.catalog\\_SP.validateVariableValue\\_SP\n\n</td></tr><tr><td>\n\n[UI category](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/application-development/automated-test-framework-atf/test-steps-ui-category.md)\n\n</td><td>\n\natf.uiTestScript.runTest\n\n</td></tr></tbody>\n</table>"}}