                 }
                 #endif
 
+                #if canImport(Combine)
+                if #available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) {
+                    then("receives nil update with publisher") {
+                        self.keyStore.testOptionalValue = DefaultsKey<Serializable?>("test")
+
+                        var update: Serializable? = self.defaultValue
+                        let cancellable = defaults.publisher(for: \.testOptionalValue)
+                            .sink { value in
+                                update = value
+                            }
+                        defaults.testOptionalValue = self.defaultValue
+                        defaults.testOptionalValue = nil
+
+                        expect(update).toEventually(beNil())
+                    }
+                }
+                #endif
+
                 then("remove observer on dispose") {
                     let key = DefaultsKey<Serializable?>("test")
 

import Nimble
@testable import SwiftyUserDefaults

protocol DefaultsSerializableSpec {
    associatedtype Serializable: DefaultsSerializable & Equatable



                    expect(update?.oldValue).toEventually(beNil())
                    expect(update?.newValue).toEventually(beNil())
                }
                #endif

                #if canImport(Combine)
                if #available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) {
                    then("remove observer on dispose with publisher") {
                        self.keyStore.testOptionalValue = DefaultsKey<Serializable?>("test")

                        var update: Serializable? = self.defaultValue
                        let cancellable = defaults.publisher(for: \.testOptionalValue)
                            .sink { value in
                                update = value
                            }

                        cancellable.cancel()
                        defaults.testOptionalValue = self.customValue

                        expect(update).toEventuallyNot(equal(self.customValue))
                    }
                }
                #endif
            }
