Specsheet

defaults — the Apple settings database

The defaults check searches the local macOS defaults database, and asserts that keys are present or missing. This database contains the configuration of applications that use it, including the standard system preferences and well-behaved third-party apps.

Examples

Check that a value is set:

[[defaults]]
domain   = 'Apple Global Domain'
key      = 'AppleAquaColorVariant'
value    = 6

Because this uses the defaults command, you can pass a valid value as the wrong type (such as the string '6' instead of the number 6) and still have it be set to the correct type.

Check that a value is not set:

[[defaults]]
domain   = 'Apple Global Domain'
key      = 'TireCount'
state    = 'missing'

Some applications will store their preferences in a separate file. Safari, for example, puts its settings in a file deep within ~/Library/Containers. To check it, do this:

[[defaults]]
file   = '~/Library/Containers/com.apple.Safari/Data/Library/Preferences/com.apple.Safari'
key    = 'ShowIconsInTabs'
value  = '1'

List of parameters

parameterstructuredescription
domainstringThe defaults domain.
filestringPath to the defaults file on disk.
keystringThe defaults key.
statestringWhether the key should be present. This can be 'present' or 'missing'.
valuestring, array, booleanThe value to expect.